显示JSON阵列I有一个JSON字典以这种格式iOS装置:在的UISearchBar
{
"382" : "sudhir kumar",
"268" : "David ",
"385" : "aayush test",
"261" : "Mike watson",
"277" : "TestDrivers Driver",
"381" : "sudhir kumar",
"380" : "sudhir kumar",
"383" : "asdfgh asdfgh",
"376" : " "
}
我在的UISearchBar来显示它。有人请帮我把它解决了,当我选择我使用下面的代码它过滤的名称,但不是他们的相关的编号与名称
我的代码是从搜索其各自的标识也选择
任何名称:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;
{
tempArray = [NSArray arrayWithArray:DriverNameArray];
//NSString *stringToSearch = textField.text;
tempId = [NSArray arrayWithArray:DriverIdArray];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@",searchText]; // if you need case sensitive search avoid '[c]' in the predicate
//NSPredicate * predicateid = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@",stringToSearch];
NSArray *tempresults = [DriverNameArray filteredArrayUsingPredicate:predicate];
if (tempresults.count > 0)
{
tempArray = [NSArray arrayWithArray:tempresults];
tempId = [NSArray arrayWithArray:tempresults];
}
[SEarchTable reloadData];
//return YES;
}
你试过的什么显示你的代码? –
请检查我更新的问题 – Abhi