I\'m playing around with realm (currently 0.85.0) and my application uses the database to store user-specific data such as the contacts of the current user. When the user de
RealmSwift: Simple reset using a flag
Tried the above answers, but posting one more simple way to delete the realm file instead of migrating:
Realm.Configuration.defaultConfiguration.deleteRealmIfMigrationNeeded = true
This simply sets a flag so that Realm can delete the existing file rather than crash on try! Realm()
Instead of manually deleting the file
Thought that was simpler than the Swift version of the answer above:
guard let path = Realm.Configuration.defaultConfiguration.fileURL?.absoluteString else {
fatalError("no realm path")
}
do {
try NSFileManager().removeItemAtPath(path)
} catch {
fatalError("couldn't remove at path")
}