Imran
Imran

Reputation: 779

Realm: How to temporarily store objects in Realm without persisting it?

I want to store temporarily some Objects in to realm without persisting it for the next launch. In the realm documents I see that it says for updating and adding you have to use inside a write transaction.

Upvotes: 2

Views: 1520

Answers (1)

kishikawa katsumi
kishikawa katsumi

Reputation: 10573

You can use in-memory Realm and multiple Realms in the app. So you use in-memory Realm for the objects that you do not want to persist. Otherwise, use normal Realm for the objects should be persisted.

let realm = Realm(inMemoryIdentifier: "MyInMemoryRealm")

Please see also https://realm.io/docs/swift/latest/#in-memory-realms for more details.

Upvotes: 3

Related Questions