1.搜索的string获取
NSArray *array = @[@"Abc", @"Beijing", @"12Bei"];
//区分
NSPredicate *predt0 = [NSPredicate predicateWithFormat:@"self contains %@",@"B"];
NSLog(@"--区分---%@",[array filteredArrayUsingPredicate:predt0]);
// 不区分
NSPredicate *predt1 = [NSPredicate predicateWithFormat:@"self contains [cd] %@",@"B"];
NSLog(@"---不区分--%@",[array filteredArrayUsingPredicate:predt1]);
2.直接的比较
区分的:系统的就默认区分。
不区分:
BOOL result0 = [@"Beijing" caseInsensitiveCompare:@"beijing"] == NSOrderedSame;
NSLog(@"--result0-----:%d",result0);
BOOL result1 = [@"Beijing" compare:@"beijing" options:NSCaseInsensitiveSearch | NSNumericSearch] == NSOrderedSame;
NSLog(@"--result1-----:%d",result1);