I have an application using Realm.io that on logout, we totally destroy the realm cache that has been built up by the user so that when a new user logs in, we can recreate the cache file for the next user.
Deleting all objects is not an option as the realm file is encrypted using a hash of the users passcode so it has to be a fresh Realm (AFAIK).
Currently I am deleting the Realm file like so:
NSString *realmFile = [[DCMCacheManager documentsDirectoryPath] stringByAppendingPathComponent:@"myApp.realm"];
NSFileManager *localFileManager = [NSFileManager new];
[localFileManager removeItemAtPath:realmFile error:&error];
And reinstating it using:
RLMRealm * realm = [RLMRealm realmWithConfiguration:config error:&error];
When the creation code runs for the first time the realm file is created with no issues. When I try to recreate it after deleting, the app seems to return an internally cached version of the realm file so does not create the myApp.realm file for me.
Any suggestions on how to make sure the realm is absolutely dead when I delete it?