ios - CoreData, NSPredicate and fetchRequest puzzling behaviour - or is it just me? -


i have encountered odd scenario when using coredata, nspredicate , fetchrequest.

my predicate is:

predicate = nspredicate(format: "(status == %d) , (watched == no) , (user_id == %@)", argumentarray: [int(itemstatus.shortlisted.rawvalue), false, userid]) 

if run fetchrequest above predicate, 0 results. if swap user_id clause watched clause, expected result.

if use nscompundpredicate, individual clauses broken down sub-predicates, using:

request.predicate = nscompoundpredicate(type: .andpredicatetype, subpredicates: [subpredicate1, subpredicate2, subpredicate3]) 

the outcome expect.

i not clear why why there discrepancy between 3 approaches.

thoughts?

taking guess, (my core data little rusty) looks have specified 3 arguments in argument array, predicate using 2 of them.

with (watched == no), you've specified value inline rather "%" delimited format, won't use "false" argument array.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -