Reputation: 23
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'
Upvotes: 2
Views: 847
Reputation: 1578
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:].
Upvotes: 7