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

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -