简体   繁体   中英

Adding Persistent Store in Apportable

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM