我正在试用 Apportable 的完整版本,但无法让它成功添加持久存储。我通过以下代码添加持久存储:
NSURL *storeURL = [NSURL fileURLWithPath:self.pathToStoreFile];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:_managedObjectModel];
// Allow inferred migration from the original version of the application.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(managedObjectStore:didFailToCreatePersistentStoreCoordinatorWithError:)]) {
[self.delegate managedObjectStore:self didFailToCreatePersistentStoreCoordinatorWithError:error];
} else {
NSAssert(NO, @"Managed object store failed to create persistent store coordinator: %@", error);
}
}
此调用返回 false(失败)。
[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]
在此调用之前打印出变量给出:
选项:
{NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; }
打印对象 storeURL
file://localhost/data/data/au.com.afgonline.flexcontacts/files/Documents/contacts.sqlite
我已将 write_external_storage 和 write_settings 添加到 configuration.json 中的功能
与如何在 Apportable 中使用 CoreData 相关?
任何意见,将不胜感激。