• 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: NSMutableArray comparator; sorting on insert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray comparator; sorting on insert


  • Subject: Re: NSMutableArray comparator; sorting on insert
  • From: Michael Ash <email@hidden>
  • Date: Fri, 16 Jan 2009 13:13:21 -0500

On Fri, Jan 16, 2009 at 11:27 AM, David Harper <email@hidden> wrote:
> Hello,
>
> I have written a comparator that returns an NSComparisonResult based on the comparison of two objects as required for
>
>     [(NSMutableArray *)someArray sortUsingSelector:@selector(theSelector:)]
>
> Now, I want this array to remain sorted after each insert.  For now I am inserting, then sorting, but this is not ideal.  Is there a way to perform an insert using the same selector to find the correct index before inserting?

Not on the Cocoa side of things, but CFArray has CFArrayBSearchValues
which will do this for you. You'll have to write a little
CFComparatorFunction adapter to bounce the call to your ObjC method
but that's relatively straightforward.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSMutableArray comparator; sorting on insert (From: David Harper <email@hidden>)

  • Prev by Date: Re: Report writer for Cocoa?
  • Next by Date: Re: Report writer for Cocoa?
  • Previous by thread: Re: NSMutableArray comparator; sorting on insert
  • Next by thread: CABasicAnimation : Can I run a CABasicAnimation and get it's updated values on it's progress?
  • Index(es):
    • Date
    • Thread