sqlite - Crash when using NSReadOnlyPersistentStoreOption -
i using read sqlite database located in mainbundle app. in persistentstorecoordinator loading database following code:
nsdictionary *storeoptions = @{nsreadonlypersistentstoreoption : [nsnumber numberwithbool:yes]}; nserror *error = nil; _persistentstorecoordinator = [[nspersistentstorecoordinator alloc] initwithmanagedobjectmodel:[self applicationmanagedobjectmodel]]; if (![_persistentstorecoordinator addpersistentstorewithtype:nssqlitestoretype configuration:nil url:[[nsbundle mainbundle] urlforresource:@"applications" withextension:@"sqlite"] options:nil error:&error]) { nslog(@"unresolved error %@, %@", error, [error description]); abort(); }
in ios7 code crashing both in simulator, , device following error:
coredata: error: (14) i/o error database @ /var/mobile/applications/4b81aefe-03e6-4156-b52d-3452515facaf/myapp.app/applications.sqlite. sqlite error code:14, 'unable open database file' 2014-03-22 20:45:34.346 gfxhotkeys3[1369:60b] coredata: error: encountered exception i/o error database @ /var/mobile/applications/4b81aefe-03e6-4156-b52d-3452515facaf/myapp.app/applications.sqlite. sqlite error code:14, 'unable open database file' userinfo { nsfilepath = "/var/mobile/applications/4b81aefe-03e6-4156-b52d-3452515facaf/myapp.app/applications.sqlite"; nssqliteerrordomain = 14; } while checking table name store: <nssqliteconnection: 0x155b0fd0> 2014-03-22 20:45:34.372 gfxhotkeys3[1369:60b] unresolved error error domain=nscocoaerrordomain code=256 "the operation couldn’t completed. (cocoa error 256.)" userinfo=0x155b01b0 {nsunderlyingexception=i/o error database @ /var/mobile/applications/4b81aefe-03e6-4156-b52d-3452515facaf/myapp.app/applications.sqlite. sqlite error code:14, 'unable open database file', nssqliteerrordomain=14}, error domain=nscocoaerrordomain code=256 "the operation couldn’t completed. (cocoa error 256.)" userinfo=0x155b01b0 {nsunderlyingexception=i/o error database @ /var/mobile/applications/4b81aefe-03e6-4156-b52d-3452515facaf/gfxhotkeys3.app/applications.sqlite. sqlite error code:14, 'unable open database file', nssqliteerrordomain=14}
passing nil in store options, run app in simulator not on device (since can't write on mainbundle).
i can solve copying database documents , loading there, wondering why happening. using option number of years loading read sqlite mainbundle, in ios 7 crashing...
any clues?
many thanks
to open read-only store, should use
nsdictionary *storeoptions = @{nsreadonlypersistentstoreoption : @yes};
instead of @no
did.
Comments
Post a Comment