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

