Display details in second UITableViewController
My application is a simple Recipebook to understand UITableViewControllers. The application contains two UITableViewControllers. The first UITableViewController contains a UITableView with a list of the recipe names. If you select a cell you will segue to the second UITableViewController. The second UITableViewController contains a UITableView with a list of the ingredients.
The application contains the following classes:
- RecipeTableViewController (first)
- IngredientTableViewController (second)
- RecipeObject
- RecipeData
The RecipeObject Class contains two properties. One property of type NSString with the recipe name. The other property is of type NSArray with the ingredients. The RecipeObject objects are in the RecipeData class.
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 is called in the RecipeTableViewController to display the recipe names in the tableView.
Message from RecipeData class to RecipeTableViewController:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.recipes = [RecipeData allRecipes];}
Display names in the 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;
}
How to add the recipe1.ingredients array to the IngredientsTableViewController?
Any help is highly appreciated!