I have the choice of doing a migration, but I would prefer to delete everything in my defaultRealm(). How can I do this easily?
realm.deleteObjects(RLMObject.objectsInRealm(realm, withPredicate: NSPredicate(value: true)))
It's easy to delete the Realm file at app launch:~~
NSFileManager.defaultManager().removeItemAtPath(defaultRealmPath(), error: nil)
However, this code is only safe to run before any instances of
RLMRealm are created. So you should run this at the start of
As of 0.87.0 as Michael McGuire mentions below there is a deleteAllObjects method
let realm = RLMRealm.defaultRealm() realm.beginWriteTransaction() realm.deleteAllObjects() realm.commitWriteTransaction()