在我正在编写的应用程序中,我试图将幸运饼干的财富列表写入属性列表。在模拟器中,这按预期工作,一切都很好。在 iPod Touch 上,我可以很好地从所述列表中读取,但它从不更新列表。
使用模拟器更新属性列表和使用 iPod Touch 更新属性列表有什么区别吗?
if(indexEdit == [data count])
{
NSString *temp = [NSString stringWithFormat:@"%@", textField.text];
[self.data addObject:temp];
}
else
{
NSString *temp = [NSString stringWithFormat:@"%@", textField.text];
[data replaceObjectAtIndex:indexEdit withObject:temp];
}
NSString *errorDesc;
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Fortunes" ofType:@"plist"];
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:data format:NSPropertyListXMLFormat_v1_0 errorDescription:&errorDesc];
if (plistData)
{
[plistData writeToFile:bundlePath atomically:YES];
}
else
{
NSLog(errorDesc);
[errorDesc release];
}