• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie-Question: Sorting Arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Newbie-Question: Sorting Arrays (From: Pontus Ilbring <email@hidden>)
 >Re: Newbie-Question: Sorting Arrays (From: "Christoph Lauterbach" <email@hidden>)

  • Prev by Date: Re: Am I overreleasing something?
  • Next by Date: Re: xcode keeps crashing when i compile
  • Previous by thread: Re: Newbie-Question: Sorting Arrays
  • Next by thread: Re: Newbie-Question: Sorting Arrays
  • Index(es):
    • Date
    • Thread