iOS9. , , . , " " PSC?
, - , PSC, , .
, _persistentStoreCoordinator
, . , - , , PSC .
, , PSC.
- . , , , . , , , PSC.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator{
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
NSURL *storeURL = [[delegate applicationDocumentsDirectory]
URLByAppendingPathComponent:@"database.sqlite"];
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel:self.managedObjectModel];
NSError *error = nil;
if (![psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:@{NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@YES}
error:&error]) {
NSLog(@"Error adding persistent store. %@, %@", error, error.userInfo);
} else {
_persistentStoreCoordinator = psc;
}
return _persistentStoreCoordinator;
}
, , .
@JodyHagins - , , , , ? - AWillian
, , , Xcode . - , , -, .
, " ", , , ( , ).
, , , , , , .
, , , , ... ... -. , , - , ( NSManagedObjectContext, ). , , , - . , , , .
, ?
, - , SO, . , - /, PSC, PSC, .
-, . , , .
MOC , - ...
+ (void)createWithConcurrencyType:(NSManagedObjectContextConcurrencyType)concurrencyType
completion:(void(^)(NSManagedObjectContext *moc, NSError *error))completion;
MOM PSC, PSC MOC. , . performBlock
, MOC . , MOC , .
concurrency, , .
MOC .