0
复制的plist如何复制plist中在nsdefault iOS 5中我们如何在NSDefault在iOS 5中
这里是我的代码:
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPlistPath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.plist", @"Bookmark"] ];
// If it's not there, copy it from the bundle
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:myPlistPath]) {
NSString *pathToSettingsInBundle = [[NSBundle mainBundle]
pathForResource:@"Bookmark" ofType:@"plist"];
[fileManager copyItemAtPath:pathToSettingsInBundle toPath:myPlistPath error:&error];
}
[myPlistPath retain];
[myPlistPath release];
它运行在模拟器正确,但设备它崩溃。
发布崩溃日志和堆栈。它会发生什么事? – zaph