Re: Trouble using ANY operator in an NSArrayController search predicate
Re: Trouble using ANY operator in an NSArrayController search predicate
- Subject: Re: Trouble using ANY operator in an NSArrayController search predicate
- From: Jim Correia <email@hidden>
- Date: Sat, 20 May 2006 08:02:59 -0400
On May 20, 2006, at 3:56 AM, Greg Herlihy wrote:
The problem is apparently that CONTAINS is not a string operator in
predicate comparisons. According to the BNF section of the Predicates
Programming Guide the four string operators are BEGINSWITH,
ENDSWITH, LIKE
and MATCHES. So it looks like the Predicates Programming Guide
mistakenly
includes CONTAINS (which is apparently an array operator) as a string
operator in its "Predicate String Format Syntax" section.
In the operations section of the doc, it says:
CONTAINS and IN serve both as aggregate operators and string
operators, depending on the types of their arguments.
The auto-generated test UI when you drag an entity over to IB uses
predicates of the form "key contains[cd] $value" for the search
field. Based on that, my working assumption is that it should work.
Anyway, I have verified that the following predicate successfully
matches
the partial course name ("phy") against the full course name
("physics")
stored in the dictionary.
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"ANY
courses.name LIKE[cd] %@", @"*phy*"];
The problem here is that LIKE "*string*" isn't a complete replacement
for CONTAINS "string" since * doesn't match across line breaks.
_______________________________________________
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