configurePersistentStoreCoordinatorForURL:ofType: modelConfiguration: storeOptions:error

2010-06-30 Thread Chris Idou


According to the doco, the above method is used to customise creation of the 
persistent store especially with regards to the store type. So I've been using 
the below code, which works perfectly fine for NSBinaryStoreType and 
NSXMLStoreType, but with NSSQLiteStoreType I get lots of merge errors when 
saving documents that I don't get if I completely remove the below code and let 
the framework handle it. Apparently I'm doing something subtlety wrong. Does 
anyone know what? At times like this I wish Apple would make their source code 
visible to developers.




- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString 
*)fileType modelConfiguration:(NSString *)configuration 
storeOptions:(NSDictionary *)storeOptions error:(NSError **)error; {
if(![[[selfmanagedObjectContext] persistentStoreCoordinator] 
addPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:url 
options:[NSDictionarydictionaryWithObjectsAndKeys:[NSNumbernumberWithBool:YES], 
NSMigratePersistentStoresAutomaticallyOption, [NSNumbernumberWithBool:YES], 
NSInferMappingModelAutomaticallyOption, nil] error:error]){
[[NSApplicationsharedApplication] presentError:*error];
returnNO;
} else {
returnYES;
}
}



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: configurePersistentStoreCoordinatorForURL:ofType: modelConfiguration: storeOptions:error

2010-06-30 Thread Jerry Krinock

On 2010 Jun 30, at 16:42, Chris Idou wrote:

 According to the doco, the above method is used to customise creation of the 
 persistent store especially with regards to the store type.

In my documentation, it's a little different:  Configures the receiver’s 
persistent store coordinator with the appropriate stores for a given URL.

 So I've been using the below code, which works perfectly fine for 
 NSBinaryStoreType and NSXMLStoreType, but with NSSQLiteStoreType I get lots 
 of merge errors when saving documents that I don't get if I completely remove 
 the below code and let the framework handle it. Apparently I'm doing 
 something subtlety wrong. Does anyone know what?

Not subtle.  Apparently, adding a persistent store as you're doing is not 
sufficient to configure an sqlite store, whatever Apple means by that.  I'm 
not surprised!  Try invoking super.  More specifically, since it appears that 
all you want to do is add a couple of key/value pairs to the store options, do 
an internet search for mmalc's MigratingDepartmentAndEmployees Sample Code and 
override that method like he does.

 At times like this I wish Apple would make their source code visible to 
 developers.

That may have been helpful ten years ago (and the GNUStep source is still 
around).  But in the case of Core Data, I suspect that taking time out to sift 
through Apple's source code would not be very productive :))

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com