siasl
siasl

Reputation: 487

Query regarding fetchrequest for coreData

When I want to create a new Invoice or Edit an existing Invoice INV1 for a Client C1, I would like to fetch the list of all Entities which are associated with Client C1 and are not associated with any invoice yet (not invoiced yet) or are already linked with INV1.

A plain SQL representation would be

SELECT * from entries where client= c1 and (invoice IS null or invoice = INV1)

How can I write a similar predicate in CoreData?

Upvotes: 1

Views: 623

Answers (1)

The Lazy Coder
The Lazy Coder

Reputation: 11838

Try this out.

predicate = [NSPredicate predicateWithFormat:@"(invoice == nil) || (invoice == %@)", invoice];

here is a nice page to learn more

http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/Predicates/predicates.html

i normally download the pdf in the top right of the page. then i can search for what i am looking for

Upvotes: 2

Related Questions