我是核心数据的新手,我使用this来执行某些步骤,但是从iOS 10开始,默认情况下会创建方法,
- (NSPersistentContainer *)persistentContainer {
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
@synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"namanCoreData"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
abort();
}
}];
}
}
return _persistentContainer;}
关于如何将核心数据用于Action Extension的任何想法/链接/建议?救命 。 。 。
答案 0 :(得分:0)
你可以做同样的事情。在initWithName
之后和loadPersistentStoresWithCompletionHandler
创建NSPersistentStoreDescription
对象之前,设置其网址,然后将_persistentContainer
的{{1}}属性设置为它。
答案 1 :(得分:0)
也许这会有所帮助:
所以,在iOS10中,你只需要
完成〜