Re: Newbie-Question: Sorting Arrays
Re: Newbie-Question: Sorting Arrays
- Subject: Re: Newbie-Question: Sorting Arrays
- From: Steve Christensen <email@hidden>
- Date: Fri, 10 Jun 2005 08:06:10 -0700
On Jun 10, 2005, at 7:32 AM, Christoph Lauterbach wrote:
Now I took this method into MyClass:
- (NSComparisonResult) compareRecord:(Record *)r
{
return [[NSString stringWithFormat:@"%@, %@, %@, %@, %f",
[self date], [self project],
[self
category], [self description], [self time]]
compare:
[NSString stringWithFormat:@"%@, %@, %@, %@, %f",
[r date], [r project], [r
category], [r description], [r time]]];
};
and call it by:
[records sortUsingSelector:@selector(compareRecord:)];
By building the app, I get the following warnings:
Record.m:105: warning: multiple declarations for method `compare:'
/.../NSValue.h:53: warning: using
`-(NSComparisonResult)compare:(NSNumber
*)otherNumber'
/.../NSDate.h:29: warning: also found `-
(NSComparisonResult)compare:(NSDate *)other'
/.../NSString.h:72: warning: also found `-
(NSComparisonResult)compare:(NSString *)string'
How can I determine the function it uses?
Well, stringWithFormat is defined as:
+ (id)stringWithFormat:(NSString *)format, ...;
You probably just need to cast the result so the compiler knows which
version of compare: you want to use.
return [(NSString*) [NSString stringWithFormat: ...]
compare: [NSString stringWithFormat: ...]];
steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden