NSPersistentStoreCoordinator to offer a convenience constructor to avoid boilerplate
| Originator: | amorya | ||
| Number: | rdar://13242852 | Date Originated: | 19-Feb-2013 11:47 AM |
| Status: | Resolved: | ||
| Product: | iPhone SDK | Product Version: | 6.0 |
| Classification: | Enhancement | Reproducible: | Not Applicable |
Working with the common use case of Core Data requires a lot of boilerplate code. In Apple's Xcode templates, this is thrown into the app delegate. I'd like to propose a new convenience constructor for NSPersistentStoreCoordinator, that avoids the need for it: [NSPersistentStoreCoordinator persistentStoreCoordinatorWithModelName:storePath:storeType:seedStoreName:automaticallyMigrate:options:error:] We would also need a new API: - defaultManagedObjectContext; The constructor takes a model name (which is assumed to be a file in the main bundle), a store path (full path to the persistent store), a store type, a seed store path (which can be nil — but if this parameter is passed in, then if the store path is empty it copies the seed store from the application bundle to the store path, rather than creating an empty store), a BOOL for whether to automatically migrate (this is such a commonly used option that it needs its own parameter), any further options, and an out error. The default managed object context method just returns a singleton managed object context. The user is at complete liberty to create further managed object contexts (and indeed, they should do if they want to customise things like concurrency type), but this should get them going.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!