Core Data: case insensitive "equals" predicate strings!?
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