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
Post a Comment