我有一个 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];