-1

我有一个 iPhone 应用程序,我必须在运行时修改 plist。我可以在模拟器上成功地做到这一点,但是当我在设备上运行它时,它会从旧的 plist 中检索数据并且没有完成修改。这是我用来获取 plist 路径的代码 -

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Customer.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];

if (![fileManager fileExistsAtPath: path])
{
    path = [[NSBundle mainBundle] pathForResource:@"Customer" ofType:@"plist"];
}



NSMutableDictionary *mainDictionary;
mainDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
4

1 回答 1

0

要在 plist 文件上编写字典,此行可能有效

[dicionaryToWrite writeToFile:path atomically: TRUE];
于 2013-11-12T19:15:04.327 回答