BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Trouble using ANY operator in an NSArrayController searchpredicate

    0 answers - 2518 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    The CNTAINS operator tests whether an array contains a specific value - so
    as an array operator CNTAINS performs strictly value comparisons. So
    CNTAINS returns true only when the search string and the string value
    exactly match - just as "key contains[cd] $value" will only be true for a
    key that exactly matches $value.
    More sophisticated string searches (such as partial string comparisons)
    require one of the string operators. which MATCHES is the most capable
    (and can deal with matching carriage returns). The MATCHES operator cannot
    be used in a fetch request against an SQL store, however, but it can be used
    to filter an array of fetched objects.
    Greg
    5/20/06 5:02 AM, "Jim Correia" <jim.correia (AT) pobox (DOT) comwrote:
    May 20, 2006, at 3:56 AM, Greg Herlihy wrote:

    >The problem is apparently that CNTAINS 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 CNTAINS (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:
    CNTAINS 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 CNTAINS "string" since * doesn't match across line breaks.
    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com
    This email sent to bsdarchive (AT) developershed (DOT) com

Re: Trouble using ANY operator in an NSArrayController searchpredicate


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 3 =
QUESTION ON "BSD"

EMSDN.COM