ios - Core Data addPersistentStoreWithType return nil, but error is nil too -


i'm creating nspersistentstore code below.

nspersistentstore * pc = [persistentcoordinator                               addpersistentstorewithtype:encryptedstoretype                                           configuration:nil                                                      url:databaseurl                                                 options:options                                                    error:error];  if (*error) {     nslog(@"unable add persistent store.");     nslog(@"error: %@\n%@\n%@", *error, [*error userinfo], [*error localizeddescription]); } 

the value of options is

{     encryptedstore = sqlite;     encryptedstoredatabaselocation =   "file:///var/mobile/containers/data/application/0c27f628-3ff0-467f-8ef1-5974ebbd3620/documents/dbencrypted.sqlite";     encryptedstorepassphrase = "xxxxxxxxredactedxxxxxxx";     nsinfermappingmodelautomaticallyoption = 1;     nsmigratepersistentstoresautomaticallyoption = 1;     nssqlitepragmasoption =     {         synchronous = off;     }; } 

at point *error nil , pc nil too.

according apple's documentation if function returns nil should error. saw before?

the encryptedstoretype https://github.com/project-imas/encrypted-core-data

the error happens if migrating data store

edit: full code of method:

+ (nspersistentstorecoordinator *)makestorewithoptions:(nsdictionary *)options managedobjectmodel:(nsmanagedobjectmodel *)objmodel error:(nserror *__autoreleasing *)error {     nspersistentstorecoordinator * persistentcoordinator = [[nspersistentstorecoordinator alloc] initwithmanagedobjectmodel:objmodel];      //  nsstring* appsupportdir = [nssearchpathfordirectoriesindomains(nsapplicationsupportdirectory, nsuserdomainmask, yes) objectatindex:0];      bool backup = yes;     nsurl *databaseurl;     id dburl = [options objectforkey:encryptedstoredatabaselocation];     if(dburl != nil) {         if ([dburl iskindofclass:[nsstring class]]){             databaseurl = [nsurl urlwithstring:[options objectforkey:encryptedstoredatabaselocation]];             backup = no;         }         else if ([dburl iskindofclass:[nsurl class]]){             databaseurl = dburl;             backup = no;         }     }      if (backup){         nsstring *dbnamekey = (__bridge nsstring *)kcfbundlenamekey;         nsstring *dbname = nsbundle.mainbundle.infodictionary[dbnamekey];         nsfilemanager *filemanager = [nsfilemanager defaultmanager];         nsurl *applicationsupporturl = [[filemanager urlsfordirectory:nsdocumentdirectory indomains:nsuserdomainmask] lastobject];         [filemanager createdirectoryaturl:applicationsupporturl withintermediatedirectories:no attributes:nil error:nil];         databaseurl = [applicationsupporturl urlbyappendingpathcomponent:[dbname stringbyappendingstring:@".sqlite"]];      }      [persistentcoordinator addpersistentstorewithtype:encryptedstoretype configuration:nil url:databaseurl         options:options error:error];      if (*error)     {         nslog(@"unable add persistent store.");         nslog(@"error: %@\n%@\n%@", *error, [*error userinfo], [*error localizeddescription]);     }      return persistentcoordinator; } 

i call in

- (void) initcoredataproperties {     nserror *error;      // creating managed object model momd     nsurl *modelurl = [[nsbundle mainbundle] urlforresource:tbcoredatamodelfilename withextension:@"momd"];     _managedobjectmodel = [[nsmanagedobjectmodel alloc] initwithcontentsofurl:modelurl];      // creating encrypted store persistent coordinator     _persistentstorecoordinator = [encryptedstore makestorewithoptions: [self persistentstoreoptions]                                                     managedobjectmodel: self.managedobjectmodel                                                                  error: &error]; 

first, not check error error state. check return of call -addpersistentstorewithtype.... error can populated in non-error condition.

your code looks fine suspect if turned off encrypted store , used apple provided sqlite store work fine. means issue third party code.

since third party code not providing error or nspersistentstore failing poorly , need open bug against code base author can address it.

or can walk through third part code , see failing , why.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -