Predicate 谓词不区分大小写

/**
 Theme: Predicate for Case-Insensitive
 IDE: Xcode 6
 Language: Objective C
 Date: 104/05/12
 Author: HappyMan
 Blog: https://cg2010studio.wordpress.com/
 */
    // 使用predicate來搜尋AND包含name,text,tag
    NSArray *searchArray = [matchText componentsSeparatedByString:@" "];
    NSMutableArray *parr = [NSMutableArray array];
    for (int i = 0; i < [searchArray count]; i++) {
        [parr addObject:[NSPredicate predicateWithFormat:@"(SELF CONTAINS[cd] %@)", searchArray[i]]];
    }
    NSPredicate *thePredicate = [NSCompoundPredicate andPredicateWithSubpredicates:parr];
 
    // 組合text,name,tag
    NSString *compoundStr = [NSString stringWithFormat:@"%@ %@ %@", originalString, senderName, tagName];
    BOOL isMatch = [thePredicate evaluateWithObject:compoundStr];

你可能感兴趣的:(Predicate 谓词不区分大小写)