【发布时间】:2015-09-26 15:39:42
【问题描述】:
每当用户点击星星时,我都会尝试将对象添加到 plist。我在另一个表视图中显示对象时遇到问题,我强烈怀疑问题出在此方法中。
-(IBAction)favbutton
{
NSString *path = [[NSBundle mainBundle] pathForResource: @"Favorites" ofType:@"plist"];
// Build the array from the plist ------>>>
NSDictionary *favs = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
favMutArray = [favs objectForKey:@"Name"];
[favMutArray addObject:stateName];
[favMutArray writeToFile:path atomically:YES];
NSLog(@"StateButtonFinished");
}
按钮已连接(通过查看 NSLog),stateName 是一个 NSString,Favorites.plist 包含带有名称、电话、传真和地址数组的根目录。如果您需要更多信息,我可以提供。谢谢!
【问题讨论】:
-
应用的资源包是只读的。
标签: ios objective-c