FROM : Frank Reiff
DATE : Mon Jan 07 21:29:40 2008
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
DATE : Mon Jan 07 21:29:40 2008
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
| Related mails | Author | Date |
|---|---|---|
| Frank Reiff | Jan 7, 21:29 | |
| mmalc crawford | Jan 7, 23:01 | |
| Ken Thomases | Jan 7, 23:22 | |
| Frank Reiff | Jan 8, 17:03 | |
| mmalc crawford | Jan 8, 17:33 | |
| Ken Thomases | Jan 9, 01:22 | |
| mmalc crawford | Jan 9, 02:53 | |
| Ken Thomases | Jan 11, 01:55 | |
| slasktrattenator | Jan 11, 11:46 | |
| Frank Reiff | Jan 11, 17:22 |






Cocoa mail archive

