• 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: Efficient searching of an NSArray of NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficient searching of an NSArray of NSDictionary


  • Subject: Re: Efficient searching of an NSArray of NSDictionary
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 29 Sep 2009 11:07:10 -0700


On Sep 29, 2009, at 7:38 AM, Pascal Harris wrote:

I have an application with an NSArray of NSDictionary (with 18 keys) which
populates an NSTableView. I am concerned that my method of accessing the
contents of my array are sub-optimal and I'm therefore seeking advice from
the experts.

Is your concern based on an actual slowdown? Have you loaded up a big data-set and measured the search time? Or do you know your algorithms well enough to be able to predict really bad behavior (like O(n^2) time) with large data?


If not, I would ignore this optimization until and unless it becomes necessary. Modern CPUs are insanely fast.
If so, profile your code to see where the time is going; sometimes the results are unintuitive.


Using predicates isn't likely to help any, because they're just a higher-level way of doing the same kind of search you'd write by hand, only a bit slower because they're interpreted. CoreData can in some cases be faster if it can do the search at the underling SQL layer. There are other ways you can change your data structures slightly and get a speedup, such as keeping your arrays sorted and doing a binary search.

—Jens_______________________________________________

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: 
 >Efficient searching of an NSArray of NSDictionary (From: Pascal Harris <email@hidden>)

  • Prev by Date: Re: Efficient searching of an NSArray of NSDictionary
  • Next by Date: Fast transition between two graphics
  • Previous by thread: Re: Efficient searching of an NSArray of NSDictionary
  • Next by thread: Fast transition between two graphics
  • Index(es):
    • Date
    • Thread