I think NSPredicate has a rough description on the Internet, so I plan to read the document first. However, the English level is limited. Therefore, I will first translate it again to better understand it. (If you have any mistakes, please correct me ). The overview NSPredicate class is used to define logical condition constraints or filter searches in memory. You can use predicates to represent logical conditions, which are used to describe the object persistence stored in the memory for object filtering. Although it is common to directly create predicates from NSComparisonPredicate, NSCompoundPredicate, and NSExpression instances, you will often use NSPredicate's class method to parse format strings to create predicates. Examples of predicate format strings include: simple comparison, such as grade = "7" or firstNamelike "Shaffiq", which does not distinguish between case and tone, for example, namecontains [cd] "itroen" logical operations, such as (firstName like "Mark") OR (lastName like "Adderley") In OS X v10.5 and later, you can create € your between € your predicates such as datebetween {$ YESTERDAY, $ TOMORROW }. you can create relational predicates, such as group. name like "work *" ALL children. age> 12ANY children. age> 12 you can create a predicate operation, such as @ sum. items. price <1000. For complete syntax reference, see "predicate programming guide ". You can also create a predicate that contains a variable so that the predicate can be pre-defined before the runtime replaces the specific value. In OS x v10.4, The predicateWithSubstitutionVariables: and evaluateWithObject :). In OS x v10.5 and later, you can use evaluateWithObject: substitutionVariables:, which combines these steps. Task creation predicates: [plain] view plaincopy + predicateWithFormat: argumentArray: + predicateWithFormat: arguments:-evaluation: + predicateWithValue: + evaluation: Evaluate a predicate: [plain] view plaincopy-evaluateWithObject: substitutionVariables: Obtain the string representation: [plain] view plaincopy-predicateFormat class method 1. predicateWithBlock: Creates and returns a predicate to evaluate the use of the specified block object and the bound dictionary.. + (NSPredicate *) predicateWithBlock :( BOOL (^) (id evaluatedObject, NSDictionary * bindings) block; parameter block is applied to the evaluated object. The block has two parameters: evaluatedObject: The evaluated object. Bindings: Replace the dictionary of variables. The dictionary must contain key-value pairs of all variables in the receiver. If the evaluatedObject calculation result is true, YES is returned for this block; otherwise, NO is returned. Return Value: an evaluation object uses a block predicate. This method is supported in memory and atomic storage of OS X v10.6.Core Data, but SQLite-based storage is not supported. Validity 4.0 and later valid Declaration on NSPredicate. h 2. predicateWithFormat: Creates a new string from the given format and resolution result to create and return a new predicate. + (NSPredicate *) predicateWithFormat :( NSString *) format,... parameter format: format String Of the new predicate. ...: List of parameters separated by commas. Return a new predicate, which is obtained by creating a new format string and parsing the result (that is, the new format string. To discuss the restrictions on the Format and variable replacement of Format strings, see Predicate Format String Syntax. Valid for IOS 3.0 and later versions. Related code example ThreadedCoreData ToolbarSearch WeatherMap is declared in NSPredicate. h 3. predicateWithFormat: argumentArray: Creates and returns a new predicate. The values in the array are passed into the format string and parsed. + (NSPredicate *) predicateWithFormat :( NSString *) predicateFormat argumentArray :( NSArray *) arguments parameter predicateFormat: Format String Of the new predicate. Arguments: array of formatted strings. The values in the array follow the order in the array. Return a new predicate. Values in the array are entered into the format string in order and parsed. To discuss the restrictions on the Format and variable replacement of Format strings, see Predicate Format String Syntax. Valid for IOS 3.0 and later versions. Declared in NSPredicate. h 4. predicateWithFormat: arguments: Creates and returns a new predicate. The parameters in the parameter list are substituted into the format string and parsed. PredicateFormat: Format String Of the new predicate. ArgList: Content in the format predicate. The order in which the parameter lists appear in the list. Return a new predicate. Values in the parameter list are entered into the format string in sequence and parsed. To discuss the restrictions on the Format and variable replacement of Format strings, see Predicate Format String Syntax. Valid for IOS 3.0 and later versions. Declared on NSPredicate. h5.predicateWithValue: Creates and returns a predicate by evaluating a given value. + (NSPredicate *) predicateWithValue :( BOOL) value parameter value: value to be evaluated by the new predicate. Return Value evaluates a worthwhile predicate. Valid for IOS 3.0 and later versions. Declared in NSPredicate. h instance method 1. evaluateWithObject: returns a given BOOL value to indicate whether a given object matches a special condition of the recipient. -(BOOL) evaluateWithObject :( id) object parameter objec: the object evaluated by the receiver. Return Value: if the object matches the recipient's special conditions, YES is returned. Otherwise, NO. is valid for IOS 3.0 and later. Declared on NSPredicate. h 2. evaluateWithObject: substitutionVariables: returns a given BOOL value to indicate whether a given object matches the special condition of the recipient after the value of a given variable dictionary is substituted. -(BOOL) evaluateWithObject :( id) object substitutionVariables :( NSDictionary *) variables parameter objec: the object evaluated by the receiver. Variables: Replace the dictionary of variables. The dictionary must contain key-value pairs of all the variables of the receiver. If the returned values are all matched, YES is returned. Otherwise, NO. This method and the two steps are discussed. "First, reference the receiver's predicateWithSubstitutionVariables: Then reference the returned predicate evaluateWithObject:" The returned result is the same. This method is optimized when predicates with different variable replacement are evaluated repeatedly. Valid for IOS 3.0 and later versions. Declared in NSPredicate. h3.predicateFormat to return the recipient's format string. -(NSString *) the format string of the receiver returned by predicateFormat. Special considerations: the string returned by this method cannot be the same as the string returned by the predicateWithFormat: method. You cannot use this method to create a persistent expression of a predicate, but you can use it to reproduce the original predicate. If you need a predicate persistence representation, you can create an archive (NSPredicate adopts the NSCoding Protocol) to be valid for IOS 3.0 and later. Declared in NSPredicate. h 4. predicateWithSubstitutionVariables: returns a copy of the receiver by replacing the variable of the receiver with the value in the given replacement dictionary. -(NSPredicate *) predicateWithSubstitutionVariables :( NSDictionary *) variables parameter variables: Replace the variable dictionary. The dictionary must contain key-value pairs whose receiver has variable names. The value of the returned receiver is replaced by a special variable. The discussion recipient itself will not be changed by the method, so you can use any number of replicas again. Valid for IOS 3.0 and later versions. Declared on NSPredicate. h