Re: Core Data Fetch Error - Followup
Re: Core Data Fetch Error - Followup
- Subject: Re: Core Data Fetch Error - Followup
- From: John Bishop <email@hidden>
- Date: Sat, 11 Mar 2006 09:12:52 -0600
email@hidden said:
Now I know why I subscribe to this list... there are some smart dudes here.
Greg, Chris and Ashley, thank you. I'm embarrassed to tell you that some code
I didn't send along was supposed to filter out cases where searchText was nil.
Thus, this predicate will result in an exception being raised during the fetch
with searchText nil:
> NSPredicate *searchPredicate = [NSPredicate
>predicateWithFormat:@"countryName like[c] %@", searchText];
>Which fails (intermittently unfortunately) with:
>
>2006-03-10 16:08:23.035 App[2060] Can't do regex matching, reason: Can't open
>pattern U_ILLEGAL_ARGUMENT_ERROR (string Korea, pattern , case 1, canon 0)
As for the suggestion to use CONTAINS rather than LIKE to avoid regex parsing
(a good suggestion, except LIKE only parses ? and * characters) - that doesn't
quite do what I need. If I'm trying to fetch items whose name would
essentially meet NSString's isEqualToString: comparison, or better,
caseInsensitiveCompare: results, CONTAINS doesn't do that... LIKE is much
closer to what I need. In my particular example, both "Northern Ireland" and
"Ireland" CONTAIN "Ireland", but only "Ireland" is LIKE "Ireland". Worse,
"Ireland", "Finland", "Greenland", "Swaziland" all CONTAIN a user request like
"land", but none of them are LIKE it. As I understand it, "==" is not for
strings and doesn't support the [cd] options. I could use a compound
predicate, I suppose, (CONTAINS AND countryName.length == searchText.length)
to tighten it up, but don't know enough about UniCode string length tests to
know if this is legal.
It's all better now... thank you.
------------------------------------------------------------------
John Bishop <mailto:email@hidden>
Mulligan Software <http://www.mulligansoftware.com>
Mulligan's Golf Personal - Stats & Handicapping for the Mac Golfer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden