Re: NSPredicate and NSString with whitespace gives runtime error
Re: NSPredicate and NSString with whitespace gives runtime error
- Subject: Re: NSPredicate and NSString with whitespace gives runtime error
- From: Ben Gollmer <email@hidden>
- Date: Mon, 22 Apr 2013 12:15:42 -0400
On Apr 22, 2013, at 10:58 AM, Koen van der Drift <email@hidden> wrote:
> Is there a way I can use an NSPredicate to search an NSString that contains whitespaces (a sentence)? If I use this:
>
> NSPredicate *functionPredicate = [NSPredicate predicateWithFormat: @"function CONTAINS[cd] %@", searchString];
>
> I keep getting a runtime error:
>
> 'NSInvalidArgumentException', reason: 'Unable to parse the format string "function CONTAINS[cd] %@"'
>
>
> My guess is this happens because the attribute contains whitespace, since I have a bunch of similar NSPredicates that searches one-word attributes, and I don't get the error.
The problem may be the use of the word "function" in your predicate string. See this SO question:
http://stackoverflow.com/questions/15801537/unable-to-parse-the-format-string-function-when-using-nspredicates-pr
--
Ben
_______________________________________________
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