我有 NSMutableArray 如下:
在.h
@property (nonatomic,retain) NSMutableArray *arrReceipes;
在.m
@synthesize arrReceipe;
在方法内部
arrReceipes = [[NSMutableArray alloc] init];
NSArray *arrReceipesTime1;
NSArray *arrReciepHeart;
NSArray *arrRecipeLifestyle;
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",@"Outdoor cooking", nil];
NSDictionary *arrRecipeLifestyleDict = [NSDictionary dictionaryWithObject:arrRecipeLifestyle forKey:@"Find Recipes"];
[arrReceipes addObject:arrReceipeTime1Dict];
[arrReceipes addObject:arrRecipesHeartDict];
[arrReceipes addObject:arrRecipeLifestyleDict];
那就是“arrReceipes”是我的 NSMutable 数组。
现在我想提取“arrReceipes”的值/字符串并将其放入“NSArray * somevariable”中。
我怎样才能做到这一点?
我这样做是为了:
-(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];
}
}
在我上面的第 3 行中(在“if”中),如果我在“main”方法中给出“arrReceipes”它的抛出异常。但是,如果不是给出“arrReceipes”,我会给“somevariable”它的工作正常。
希望你能理解我的问题。请帮忙。谢谢。