我有一个UITableView控制器,当选择一行时,我想将该行的配方添加到NSMutableArray addedRecipesArray,这是AppDelegate的一个属性。但是,我可以告诉我,根据我设置的NSLog,实际上没有添加任何配方到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);
}
}