• 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: "Christoph Lauterbach" <email@hidden>
  • Date: Fri, 10 Jun 2005 16:32:28 +0200 (MEST)

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?

Sorry for my bad English.

Greetings
Christoph


> --- Ursprüngliche Nachricht ---
> Von: Pontus Ilbring <email@hidden>
> An: Christoph Lauterbach <email@hidden>
> Kopie: email@hidden
> Betreff: Re: Newbie-Question: Sorting Arrays
> Datum: Fri, 10 Jun 2005 16:08:45 +0200
>
> On 6/10/05, Christoph Lauterbach <email@hidden> wrote:
> > Hi,
> >
> > I am a newbie to Cocoa, so please be appreciative for my question:
> >
> > I have an mutable array with objects with contain among others a
NSDate
> > object and a NSString object.
> >
> > I want to sort the array in ascending order by the NSDate object and
> > secondly by the NSString object.
>
> If I've understood things right you have some kind of class MyClass
> whose instances holds those dates and strings.
>
> Read the documentation for NSDate's and NSString's compare: methods.
> You'll want to write a similar compare: method for MyClass that
> returns the result of comparing the dates, or the result of comparing
> the strings if the dates should be equal.
>
> Then you give this method's selector to sortUsingSelector:
>

--
Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis
++ Jetzt anmelden & testen ++ http://www.gmx.net/de/go/promail ++
 _______________________________________________
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

  • Follow-Ups:
    • Re: Newbie-Question: Sorting Arrays
      • From: Ondra Cada <email@hidden>
    • Re: Newbie-Question: Sorting Arrays
      • From: Steve Christensen <email@hidden>
References: 
 >Re: Newbie-Question: Sorting Arrays (From: Pontus Ilbring <email@hidden>)

  • Prev by Date: Archiving selection index paths with core data
  • 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