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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -