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.deleteObject(object)
is the only function along with .deleteObjects.
I have tried the following code:
Method 1
realm.deleteObjects(RLMObject.objectsInRealm(realm, withPredicate: NSPredicate(value: true)))
Method 2
realm.deleteObjects(Dog.allObjectsInRealm(realm))
realm.deleteObjects(Person.allObjectsInRealm(realm))
realm.deleteObjects(Goal.allObjectsInRealm(realm))
realm.deleteObjects(Goals.allObjectsInRealm(realm))
Both fail to prevent the migration exception.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…