Детали во втором UITableViewController
Мое приложение представляет собой простой Recipebook понять UITableViewControllers. Приложение содержит два UITableViewControllers. Первый UITableViewController содержит UITableView со списком имен рецептов. Если вы выберете ячейку, вы перейдете ко второму UITableViewController. Второй UITableViewController содержит UITableView со списком ингредиентов.Objective C - Передача данных между двумя UITableViewControllers
Приложение содержит следующие классы:
- RecipeTableViewController (первый)
- IngredientTableViewController (второй)
- RecipeObject
- RecipeData
RecipeObject Класс содержит два свойства. Одно свойство типа NSString с именем рецепта. Другое свойство имеет тип NSArray с ингредиентами. Объекты RecipeObject находятся в классе RecipeData.
RecipeObject *recipe1 = [[RecipeObject alloc]init];
recipe1.name = @"Fresh Coconut Cake";
recipe1.ingredients = [NSArray arrayWithObjects:@"Coconut cups", @"Milk", @"Baking powder", @"Butter", @"Sugar", @"Eggs", nil];
The RecipeData вызывается в RecipeTableViewController, чтобы отобразить имена рецептов в Tableview.
Сообщение от класса RecipeData к RecipeTableViewController:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.recipes = [RecipeData allRecipes];}
Отображаемые имена в Tableview:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"recipeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
RecipeObject *recipes = [self.recipes objectAtIndex:indexPath.row];
cell.textLabel.text = recipes.name;
return cell;
}
Как добавить массив recipe1.ingredients в IngredientsTableViewController?
Любая помощь очень ценится!
, который содержит много хорошей информации, но не того, что мне нужно. Мой вопрос: как мне получить массив recipe1.ingredients объекта RecipeObject в контроллере tableviewcontroller. – Nielsapp