この配列に検索機能を実装し、検索バーに入力されたテキストのみを表示するように取得する必要がある辞書を含む配列があります.... ……
私はこのコードを試しました
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if (searchText.length == 0) {
isFiltered = NO;
}
else {
isFiltered = YES;
FilteredData = [[NSMutableArray alloc]initWithArray:[ParsedData valueForKey:@"FolderName"]];
NSMutableArray *searchData = [NSMutableArray new];
for(NSDictionary *dict in ParsedData){
NSDictionary *tempDict= @{@"FolderName":dict[@"FolderName"],@"ID":dict[@"ID"]}
[searchData addObject:tempDict];
SearchData = [[NSMutableArray alloc]initWithArray:searchData];
NSLog(@"DATA %@",SearchData);
}
//Fast Enumeration
for (NSString *fileName in FilteredData)
{
NSRange fileNameRange = [fileName rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (fileNameRange.location == NSNotFound) {
[SearchData removeObject:[SearchData valueForKey:@"FolderName"]];
}
}
}
[listingSet reloadData];
}
This is the data present in parsed data as below plz check out.parse data array is getting data from an xml
2013-05-02 15:14:19.935 DocumentManagement[423:207] PARSED DATA (
{
CreatedBy = 1;
FolderName = Posteingang;
ID = 13000;
ParentID = 0;
},
{
CreatedBy = 1;
FolderName = "my folder";
ID = 13183;
ParentID = 0;
},