Okay;
In the CoreDataBooks Sample Code it is shown “for the sake of illustration”
how to copyItemAtURL:_ toURL:storeURL and then addPersistentStoreWithType:_:_:storeURL
which I pasted below for your review along with its link.
Now, how do I do this in Swift 3 Xcode 8 with the use of the new NSPersistentContainer?
Do I do this in the storeDescription:? and if so how.
Could you give me a sample snipped in swift 3 showing me how to accomplish this from CoreDataBooks sample to Xcode 8 style?
Also, do we now keep the Core Data Stack in the app delegate or should we move it to its own class as before?
Thank you
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataBooks.CDBStore"];
/*
Set up the store.
For the sake of illustration, provide a pre-populated default store.
*/
NSFileManager *fileManager = [NSFileManager defaultManager];
// If the expected store doesn't exist, copy the default store.
if (![fileManager fileExistsAtPath:[storeURL path]]) {
NSURL *defaultStoreURL = [[NSBundle mainBundle] URLForResource:@"CoreDataBooks" withExtension:@"CDBStore"];
if (defaultStoreURL) {
[fileManager copyItemAtURL:defaultStoreURL toURL:storeURL error:NULL];
}
}
.......
NSError *error;
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
.......
return _persistentStoreCoordinator;
}