【发布时间】:2011-02-02 20:29:19
【问题描述】:
一旦用户点击“添加到收藏夹”按钮,我就会尝试将对象添加到 NSMutableArray,我可以将数据放入 NSDictionary,但是当我将 NSDictionary 传递给数组时,NSLog 会返回 nil。我错过了什么吗?
-(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 中创建一个方法?当然,自学 Core Data 确实需要一些时间,但我想我现在已经掌握了它。谢谢
标签: iphone nsmutablearray