如果我想在字符串“red is a color in my crayonbox”中找到单词“color”,我该如何构造它?
谢谢,
NSString *stringToSearchFor = @"whatever you want";
[NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", stringToSearchFor];
要搜索红色或法拉利...
NSPredicate *redPred = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] 'red'"];
NSPredicate *ferraiPred = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] 'ferrari'"];
NSPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubPredicates:[NSArray arrayWithObjects:redPred, ferrariPred, nil]];