NSPredicate

NSPredicate is a Foundation class that specifies how data should be fetched or filtered. Its query language, which is like a cross between a SQL WHERE clause and a regular expression, provides an expressive, natural language interface to define logical conditions on which a collection is searched.

nshipster.com/nspredicate/

NSPredicate is a Foundation class that defines logical conditions to fetch or filter data. Its syntax mixes SQL WHERE clauses with regex for expressive queries on collections.

Examples filter people by name or age: NSPredicate(format: "firstName = 'Bob'") or "age >= 30".

Use with arrays/sets: filtered(using:), filterUsingPredicate:. For Core Data, set on NSFetchRequest.

Syntax:

Build compounds with NSCompoundPredicate (and/or). Use NSComparisonPredicate for expressions. Block predicates for custom logic, but not for SQLite Core Data.

NSPredicate shines in Cocoa for data handling, offering power few languages match in their standard libraries.


Category:

Year: