i m new в IOS developer.my проблема заключается в том, что я хочу искать данные с использованием имени элемента. Когда я набираю B, а B - данные, это display.here это мое значение msmmable array.Поиск данных с помощью панели поиска из tableview
(
{
counts = 0;
"drycleaning_price" = 10;
id = 2;
imagename = "";
"iron_price" = 16;
name = Bedsheet;
"wash_price" = 15;
"washiron_price" = 14;
},
{
counts = 0;
"drycleaning_price" = 12;
id = 3;
imagename = d;
"iron_price" = 16;
name = "Coat(Man)";
"wash_price" = 14;
"washiron_price" = 13;
},
{
counts = 0;
"drycleaning_price" = 15;
id = 4;
imagename = f;
"iron_price" = 10;
name = "Jeans(Man)";
"wash_price" = 12;
"washiron_price" = 16;
},
{
counts = 0;
"drycleaning_price" = 14;
id = 3;
imagename = "";
"iron_price" = 12;
name = "Pants(Kid)";
"wash_price" = 18;
"washiron_price" = 17;
},
{
counts = 0;
"drycleaning_price" = 15;
id = 2;
imagename = s;
"iron_price" = 10;
name = "Pants(Man)";
"wash_price" = 13;
"washiron_price" = 12;
},
{
counts = 0;
"drycleaning_price" = 12;
id = 1;
imagename = "";
"iron_price" = 32;
name = "Pillow Cover";
"wash_price" = 30;
"washiron_price" = 15;
},
здесь это мой скриншот
здесь это мой код
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView) {
return [self.searchResults count];
} else {
return [arrayCounts count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
customcell *cell = (customcell *)[self.tableview dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
cell = [[[NSBundle mainBundle] loadNibNamed:@"customcell" owner:self options:nil] objectAtIndex:0];
if (tableView == self.searchDisplayController.searchResultsTableView) {
cell.textLabel.text = [[self.searchResults objectAtIndex:indexPath.row ]objectForKey:@"name"];
cell.txt_value.text = [NSString stringWithFormat:@"%@",self.searchResults[indexPath.row][@"counts"]];
cell.lbl_price.text=[NSString stringWithFormat:@"%@",arrayCounts[indexPath.row][@"drycleaning_price"]];
} else
{
cell.txt_value.text = [NSString stringWithFormat:@"%@",arrayCounts[indexPath.row][@"counts"]];
cell.lbl_title.text=[NSString stringWithFormat:@"%@",arrayCounts[indexPath.row][@"name"]];
cell.lbl_price.text=[NSString stringWithFormat:@"%@",arrayCounts[indexPath.row][@"drycleaning_price"]];
}
[cell.stepper addTarget:self action:@selector(itemsChange:) forControlEvents:UIControlEventValueChanged];
return cell;
}
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.searchResults removeAllObjects];
NSPredicate *resultpredicate=[NSPredicate predicateWithFormat:@"SELF contains [cd] %@",self.searchResults];
self.searchResults=[[arrayCounts valueForKey:@"name" ] filteredArrayUsingPredicate:resultpredicate];
NSLog(@"searchlist %@",self.searchResults);
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar
selectedScopeButtonIndex]]];
return YES;
}
я хочу найти с помощью name.pls помочь мне bro.thank вас заранее. ...
ok Я попробую бросить – iOS
имя массива iw плохо хранить мой массив arrTempTableData yaa arrTableData – iOS