我想添加对象到NSMutableArray中,一旦用户点击添加到收藏夹按钮我可以将数据放入NSDictionary,但是当我将NSDictionary传递给数组时,NSLog出现回零。我错过了什么吗?iPhone的addObject从另一个ViewController的NSMutableArray使用IBAction
-(IBAction) addtofavorites: (id)sender
{
NSArray *key = [NSArray arrayWithObjects:@"Title", @"Description", nil];
NSArray *objects = [NSArray arrayWithObjects:CurrentTitle, description.text, nil];
NSDictionary *fadd = [[NSDictionary alloc] initWithObjects:objects forKeys:key];
FavoritesViewController *fvc = [[FavoritesViewController alloc] init];
[fvc.favorites addObject:fadd];
[FavoritesViewController release];
}
东西,所以我去一个不同的方向,但仍然有同样的问题。我现在使用核心数据保存我的收藏夹。我不知道如何将游戏添加到我的NSManagedObjectContex。我有一个叫做Games的类,想要传递3个NSString。我是否在我的AppDelegate,Games或我的ViewController中的Context中创建了一个方法?当然确实需要一段时间来教授自己的核心数据,但我认为我现在已经掌握了一些。谢谢 – 2011-03-25 17:25:23