• 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
NSFetchRequest/NSPredicate behavior for different stores
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFetchRequest/NSPredicate behavior for different stores


  • Subject: NSFetchRequest/NSPredicate behavior for different stores
  • From: "Stephen F. Booth" <email@hidden>
  • Date: Tue, 7 Nov 2006 11:12:40 -0800

All,

I have run into a problem that has me stumped. I am attempting to fetch objects matching user-specified criteria for a smart playlist implementation, and depending on the keypaths used and the type of backing store I am seeing different behavior! I am aware of the notes regarding using Cocoa-specific methods such as localizedCompare: in predicates, and I don't believe that is the problem (though it may be).

This code works fine using any store I've tested:

playlistObject = [NSEntityDescription insertNewObjectForEntityForName:@"DynamicPlaylist" inManagedObjectContext:managedObjectContext];
[playlistObject setPredicate:[NSPredicate predicateWithFormat:@"url CONTAINS[c] %@", @"nat"]];
// Results from the fetch are correct


Here is where the weirdness emerges: the following fetch works correctly using a binary store, but fails to return any results using an SQLite store:

playlistObject = [NSEntityDescription insertNewObjectForEntityForName:@"DynamicPlaylist" inManagedObjectContext:managedObjectContext];
[playlistObject setPredicate:[NSPredicate predicateWithFormat:@"metadata.title CONTAINS[c] %@", @"nat"]];
// No results found for SQLite, but correct for binary


However, the simple change of predicate to

[playlistObject setPredicate:[NSPredicate predicateWithFormat:@"metadata.title LIKE[c] %@", @"*nat*"]];

returns the expected results.

Is there an issue with using CONTAINS in predicates with keyPaths for an SQLite store? Or have I just missed something obvious?

Thanks,
Stephen

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Prev by Date: Re: Mixing Objective-C and C++
  • Next by Date: Re: Polished metal.. and tabview!
  • Previous by thread: Re: Mixing Objective-C and C++
  • Next by thread: Multiple windows/window controllers, one document and Core Data
  • Index(es):
    • Date
    • Thread