• 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
Core Data: case insensitive "equals" predicate strings!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: case insensitive "equals" predicate strings!?


  • Subject: Core Data: case insensitive "equals" predicate strings!?
  • From: Frank Reiff <email@hidden>
  • Date: Mon, 7 Jan 2008 21:29:40 +0100

Dear group,

Sorry, but this is yet another lame Core Data question: when using a predicate string to perform a fetch, e.g.

NSPredicate* predicate = [NSPredicate predicateWithFormat: @"%K == %@", @"fullDestinationPath", newFullPath];

The equals (==) is case insensitive; I need a case sensitive equals. The operations supported on strings all take modifiers, so you can write:

NSPredicate* predicate = [NSPredicate predicateWithFormat: @"%K CONTAINS[c] %@", @"fullDestinationPath", newFullPath];

where the [c] part means "case insensitive". Works like a charm, but there's no equals operation specifically for strings.. the obvious solution:

NSPredicate* predicate = [NSPredicate predicateWithFormat: @"%K ==[c] %@", @"fullDestinationPath", newFullPath];

throws an invalid argument exception.

I've had to resort to the very lame:

NSPredicate* predicate = [NSPredicate predicateWithFormat: @"%K BEGINSWITH[c] %@ AND %K ENDSWITH[c] %@", @"fullDestinationPath", newFullPath];

to get things to work properly.. surely this is not the recommended way of doing case insensitive matching for core data?

The "newFullPath" variable obviously is a string that may contain any number of special characters so wild-card matching is out. What's more this is a probably the most performance critical part of the program..

Any thoughts?

Best regards,

Frank
_______________________________________________

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: Core Data: case insensitive "equals" predicate strings!?
      • From: Ken Thomases <email@hidden>
    • Re: Core Data: case insensitive "equals" predicate strings!?
      • From: mmalc crawford <email@hidden>
  • Prev by Date: Re: CALayer Border, Not Inset
  • Next by Date: Re: Circular initialization of controllers in NIB file
  • Previous by thread: [Meeting] Toronto CocoHeads / tacow meeting tomorrow
  • Next by thread: Re: Core Data: case insensitive "equals" predicate strings!?
  • Index(es):
    • Date
    • Thread