我想搜索 NSMutalbleArray
,我的代码是:
arrCelebs=[[NSMutableArray alloc] initWithObjects:@"Test 1",@"Test 2",@"Test 42",@"Test 5", nil];
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString *arrString1 = txtSearch.text;
NSRange tmprange;
for(NSString *string in arrCelebs) {
tmprange = [arrString1 rangeOfString:string];
if (tmprange.location != NSNotFound) {
NSLog(@"String found");
break;
}
}
return YES;
}
如果我输入“t”然后它搜索所有数据,我想添加另一个数组。用于在 tableview 中显示。