ios - How to create a predicate that compares all properties of an object? -
For example, I have an object that has three properties: first name, middle name, last name.
Can I do something like this: "Includes everything" does not work in an ingenious, and ( As far as I know) there is no single syntax, get desired results. The "Code of Definition" from all the "string" attributes in the following code unit creates: [NSPredicate predicateWithFormat: @ "(first name in [CD]% @) or (last name [CD]% @) or (in middle name [Cd]% @) ", @" Joynion ", @" John ", @" Joy "];
[NSPredicate predicateWithFormat: @ "(all in [CD]% @), @" John "] ;
< code> NSString * searchText = @ "john"; NSEntityDescription * entity = [NSEntityDescription EntityForName: @ Managed objects in "Entity" (If [[attr isKindOfClass: [NSAttributeDescription class]]) {if ([attr attributeType] == NSStringAttributeType} {NSPredicate * tmp = [NSPredicate predicateWithFormat: @ "NSMutableArray array: % K contains [CD]% @ ", [the name of the deal], search text]; [subproducts addObject: tmp];}}} NSPredicate * predicate = [NSCompoundPredicate or PredicateWithSubpredicates: subPredicates]; NSLog (@ "% @", forecast); The first name is [cd] "John" or the last name [CD] is "John" or middle name [CD] "John"
Comments
Post a Comment