CoreData, automatic migration and sandbox problems.
CoreData, automatic migration and sandbox problems.
- Subject: CoreData, automatic migration and sandbox problems.
- From: Samuel Williams <email@hidden>
- Date: Tue, 29 May 2012 01:59:14 +1200
Hi,
I'm having trouble with automatic migrations and sandbox.
When the user opens an old file, the automatic migration fails due to no
write permission to the file.
-
(BOOL)configurePersistentStoreCoordinatorForURL:(NSURL*)url
ofType:(NSString*)fileType modelConfiguration:(NSString*)configuration
storeOptions:(NSDictionary*)storeOptions error:(NSError**)error
{
NSMutableDictionary *options = nil;
if (storeOptions != nil) {
options = [storeOptions mutableCopy];
} else {
options = [[NSMutableDictionary alloc] init];
}
[options setObject:[NSNumber numberWithBool:YES]
forKey:NSMigratePersistentStoresAutomaticallyOption];
[options setObject:[NSNumber numberWithBool:YES]
forKey:NSInferMappingModelAutomaticallyOption];
*//[options setObject:[NSNumber numberWithBool:YES]
forKey:NSReadOnlyPersistentStoreOption];*
BOOL result =
[super configurePersistentStoreCoordinatorForURL:url ofType:fileType
modelConfiguration:configuration storeOptions:options
error:error];
*//if (*error) {*
* // *** Fails here ****
*// [[NSAlert alertWithError:*error] runModal];*
*//}*
[options release];
return result;
}
Just wondering if anyone has a suggestion about how I can avoid writing to
the file, e.g. forcing the user to re-save or duplicate the document before
attempting the migration. It works fine for non-sandbox builds.
Kind regards,
Samuel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden