我有这样的代码:在.m
- (void)viewDidLoad
{
[super viewDidLoad];
arrReceipes = [[NSMutableArray alloc] init];
arrReceipesTime1 = [NSArray arrayWithObjects:@"Half an hour or less",@"About an hour",@"More than an hour", nil];
NSDictionary *arrReceipeTime1Dict = [NSDictionary dictionaryWithObject:arrReceipesTime1 forKey:@"Find Recipes"];
arrReciepHeart = [NSArray arrayWithObjects:@"HealthyAndDelicius", nil];
NSDictionary *arrRecipesHeartDict = [NSDictionary dictionaryWithObject:arrReciepHeart forKey:@"Find Recipes"];
arrRecipeLifestyle = [NSArray arrayWithObjects:@"Recipe for fall",@"Quick and easy",@"Cooking for kids",@"Easy entertaining",@"American classics", nil];
NSDictionary *arrRecipeLifestyleDict = [NSDictionary dictionaryWithObject:arrRecipeLifestyle forKey:@"Find Recipes"];
[arrReceipes addObject:arrReceipeTime1Dict];
[arrReceipes addObject:arrRecipesHeartDict];
[arrReceipes addObject:arrRecipeLifestyleDict];
}
现在,我想addObject:dictionaryObject
使用 segue(或任何其他方式,如果你知道的话)将值从“arrReceipes”(我正在做“”)传递到另一个视图控制器
并使用“segue”我正在使用以下内容:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
NSIndexPath *indexPath = [self.tableView1 indexPathForSelectedRow];
RecipeDetailViewController *destViewController = segue.destinationViewController;
destViewController.recipeName = [arrReceipes objectAtIndex:indexPath.row];
}
}
我遇到了异常,因为我的“arrReceipes”被NSMutableArray
分配了字典对象。如果使用“ NSMutableArray
”,则如果我使用“ NSArray
”,则它工作正常。但我想用“ NSMutableArray
”;因为有了这个我可以在表格视图中进行分组。