У меня PLIST в этом формате:Как получить конкретные детали в PLIST, чтобы показать в Tableview
Я в настоящее время показать все содержание plist.My главный вопрос это
Как я могу показать только на основе категории? У меня будет 3 категории, и я хочу, чтобы пользователь мог видеть только элемент этой категории при выборе. Посмотрите на мой первый элемент, название категории - «главное». Если пользователь выбирает основной, мне нужно показывать только основные категории.
Как это сделать?
'
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if([[UIDevice currentDevice] userInterfaceIdiom]== UIUserInterfaceIdiomPhone) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
cell.textLabel.text=[[self.content objectAtIndex:indexPath.row] valueForKey:@"recipeName"];
// NSInteger rating;
//NSString *reason;
// rating = [[self.content objectAtIndex:indexPath.row] valueForKey:@"rating"];
return cell;
// Configure the cell...
'
содержание
synthesize tableView,content=_content;
-(NSArray*) content {
if(!_content){
NSString *path = [[NSBundle mainBundle] pathForResource:@"recipes" ofType:@"plist" ];
_content = [[NSArray alloc] initWithContentsOfFile:path];
}
return _content;
}
Segue часть
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
// Get destination view
detailViewController *destViewController = [segue destinationViewController];
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSInteger tagIndex = [(UIButton *)sender tag];
destViewController.recipeName =[[self.content objectAtIndex:indexPath.row] valueForKey:@"recipeName"];
destViewController.recipeDetail =[[self.content objectAtIndex:indexPath.row] valueForKey:@"recipeDetail"];
destViewController.recipeIngredients =[[self.content objectAtIndex:indexPath.row] valueForKey:@"recipeIngredients"];
это основные части
Что ваш код? Что вы достигли до сих пор? – Larme
oh i m добавление – user3371581
@ Larme я добавил его man – user3371581