Ios 我们现有的appDelegate。这是了解核心数据堆栈是如何构造的以及它是如何工作的一个好方法。 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathCompo

Ios 我们现有的appDelegate。这是了解核心数据堆栈是如何构造的以及它是如何工作的一个好方法。 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathCompo,ios,xcode,core-data,Ios,Xcode,Core Data,我们现有的appDelegate。这是了解核心数据堆栈是如何构造的以及它是如何工作的一个好方法。 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Myapp_2.sqlite"]; NSError *error = nil; _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWi

我们现有的appDelegate。这是了解核心数据堆栈是如何构造的以及它是如何工作的一个好方法。
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Myapp_2.sqlite"];

NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil
     abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application,
     Typical reasons for an error here include:
     * The persistent store is not accessible;
     * The schema for the persistent store is incompatible with current managed object model.
     Check the error message to determine what the actual problem was.


     If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into
     If you encounter schema incompatibility errors during development, you can reduce their frequency by:
     * Simply deleting the existing store:
     [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]

     * Performing automatic lightweight migration by passing the following dictionary as the options parameter:
     @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES}

     Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration
     */
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}    

return _persistentStoreCoordinator; }