swift - way to purge all but one object types (models) in a realm -
i want realm.delete()
1 model in realm. there way without listing of them?
maybe way loop through types existing in realm?
you can access types realm configuration, filter them exclude 1 want keep delete each object of each type don't want keep.
let typetobekept = myobjectclass.self realm.configuration.objecttypes?.filter{$0 != typetobekept}.foreach{ type in try! realm.write { realm.delete(realm.objects(type.self)) } }
Comments
Post a Comment