I have a UITableView Controller and when a row is selected, I want to add that row's recipe to NSMutableArray addedRecipesArray which is a property of AppDelegate. 但是,根据我设置的 NSLogs,我可以看出实际上并没有将任何食谱添加到 addedRecipesArray 中。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
recipe = [recipesArray objectAtIndex:indexPath.row];
NSLog(@"You have added %@ to the shoppingList", recipe.recipeName);
[[[self appDelegate]addedRecipesArray] addObject:recipe];
NSLog(@"The shopping list now contains:");
for (Recipe *selectedRecipe in [[self appDelegate]addedRecipesArray])
{
NSLog(@"%@", selectedRecipe.recipeName);
}
}