我正在试用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; }
print-object storeURL
file://localhost/data/data/au.com.afgonline.flexcontacts/files/Documents/contacts.sqlite
我已将write_external_storage和write_settings添加到configuration.json中的功能
与How to use CoreData in Apportable?
相关任何建议都将受到赞赏。
答案 0 :(得分:2)