How to create a compound predicate in iOS? || multiple predicates in swift

Solution:

You can merge one or more predicates to form a predicate.Because if you do in a single predicate you can have more confusions with and or.


        let innerPredicate = NSPredicate(format: "ANY name contains[cd] %@", searchText)
        let innerQuantPredicate = NSPredicate(format: "ANY quantity contains[cd] %@", searchText)
        let outerQuantPredicate = NSPredicate(format: "ANY slNo contains[cd] %@", searchText)

        
        let compundPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: [outerPredicate, innerPredicate, titlePredicate])

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift