我已经向现有的Plist添加了新的实体。由于Plist不一致,新版本的应用程序崩溃。
如何将旧的plist数据与新的plist合并?
我的Plist创建方法如下
- (void)createEditableCopyOfFileIfNeeded:(NSString *)plistName
{
// First, test for existence.
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:plistName];
success = [fileManager fileExistsAtPath:plistPath];
if (success)
{
return;
}
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:plistName];
success = [fileManager copyItemAtPath:defaultPath toPath:plistPath error:&error];
if (!success)
{
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}提前感谢
发布于 2012-10-08 17:36:48
我会在您的plist中包含一个版本密钥,以便与应用程序的版本进行比较。您可以使用以下代码片段检查应用程序的版本:
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]然后,在应用程序启动时:
发布于 2012-10-08 17:17:31
你可以这样做:
>G29
https://stackoverflow.com/questions/12778618
复制相似问题