Multiple NSPredicates for NSFetchRequest in Swift? -


currently, have simple nsfetchrequest associated nspredicate. however, im hoping there way can append multiple predicates. i've seen examples in objective c, none swift.

can define list of nspredicate's or append multiple nspredicate objects single nsfetchrequest somehow?

thanks!

you can use "nscompoundpredicate". example:

    let converstationkeypredicate = nspredicate(format: "conversationkey = %@", conversationkey)     let messagekeypredicate = nspredicate(format: "messagekey = %@", messagekey)     let andpredicate = nscompoundpredicate(type: nscompoundpredicatetype.andpredicatetype, subpredicates: [converstationkeypredicate, messagekeypredicate])     request.predicate = andpredicate 

you can change "andpredicatetype" or "orpredicatetype"


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -