質問

I am trialing the full version of Apportable, but cannot get it to successfully add a persistent store. I am adding the persistent store via this code:

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);
    }
}

This call returns false (failure).

[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]

Printing out the variables just before this call gives:

options:

{NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; }

print-object storeURL

file://localhost/data/data/au.com.afgonline.flexcontacts/files/Documents/contacts.sqlite

I have added write_external_storage and write_settings to the features in configuration.json

Related to How to use CoreData in Apportable?

Any advice would be appreciated.

役に立ちましたか?

解決

sorry it took me so long to see this question. the answer i gave in the related question (How to use CoreData in Apportable?) that you linked may be of interest to you. more importantly, we're soon going to be shipping a new version of our platform with a lot of important and useful changes. there will be a new version of coredata shipped with this as well. i hope to soon fix the manual copying step.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top