Realm realmWithPath method in main bundle crashes on iOS

krazyeom

I do not use *.realm file in Document directory of app. I use it in main bundle directory.

When I call it:

NSString *path = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"realm"];
RLMRealm *realm  = [RLMRealm realmWithPath:path];

It crashes and logs:

Terminating app due to uncaught exception 'RLMException', reason: 'open() failed: Operation not permitted'

bmunk

The Realm file must be located in a directory to which you have write access in case you want to be able to update any data. If you only intend to distribute a preset database with your app and access it read only, you must open it read only with [RLMRealm realmWithPath:readOnly:error:].

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related