Skip navigation.
 
mlRe: Core Data: case insensitive "equals" predicate strings!?
FROM : Ken Thomases
DATE : Mon Jan 07 23:22:02 2008

On Jan 7, 2008, at 2:29 PM, Frank Reiff wrote:

> 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?


I don't see an obvious case-insensitive equals operator.  LIKE or 
MATCHES are tempting, but get you in trouble if either of the 
arguments include characters that are interpreted as meta-characters.

However, I would not use the BEGINSWITH AND ENDSWITH construction 
that you're using.  That would match if fullDestinationPath happened 
to contain the concatenation of newFullPath with itself.

I think that something like A CONTAINS[c] B AND B CONTAINS[c] A would 
be safer.

Still, you're right, it's far from elegant.

-Ken

Related mailsAuthorDate
mlCore Data: case insensitive "equals" predicate strings!? Frank Reiff Jan 7, 21:29
mlRe: Core Data: case insensitive "equals" predicate strings!? mmalc crawford Jan 7, 23:01
mlRe: Core Data: case insensitive "equals" predicate strings!? Ken Thomases Jan 7, 23:22
mlRe: Core Data: case insensitive "equals" predicate strings!? Frank Reiff Jan 8, 17:03
mlRe: Core Data: case insensitive "equals" predicate strings!? mmalc crawford Jan 8, 17:33
mlRe: Core Data: case insensitive "equals" predicate strings!? Ken Thomases Jan 9, 01:22
mlRe: Core Data: case insensitive "equals" predicate strings!? mmalc crawford Jan 9, 02:53
mlRe: Core Data: case insensitive "equals" predicate strings!? Ken Thomases Jan 11, 01:55
mlRe: Core Data: case insensitive "equals" predicate strings!? slasktrattenator Jan 11, 11:46
mlRe: Core Data: case insensitive "equals" predicate strings!? Frank Reiff Jan 11, 17:22