• 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
NSPredicate speed improvement?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPredicate speed improvement?


  • Subject: NSPredicate speed improvement?
  • From: Koen van der Drift <email@hidden>
  • Date: Sat, 01 Mar 2014 07:22:25 -0500

Consider two entities in a many-to-many relationship: Library and Book. In a NSFetchResultController backed UITableView, I like to show all the books from one library, so I constructed the following fetch request:

    NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName: @"Book"];
    NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey: @"date" ascending: YES];
    [fetchRequest setSortDescriptors: @[sort]];

    NSPredicate *predicate = [NSPredicate predicateWithFormat: @"libraries contains[cd] %@", self.library];
    [fetchRequest setPredicate: predicate];

which is then fed into the NSFetchedResultController when the view opens.

There is a noticeable delay of a few 100 ms when the view opens, and I suspect that the predicate I have is not optimal by using 'contains'.

Is there a way to improve on this?

Thanks,

- Koen.


_______________________________________________

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


  • Follow-Ups:
    • Re: NSPredicate speed improvement?
      • From: Sixten Otto <email@hidden>
  • Next by Date: Re: NSPredicate speed improvement?
  • Next by thread: Re: NSPredicate speed improvement?
  • Index(es):
    • Date
    • Thread