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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -