JDG
JDG

Reputation: 540

What is the best practice to have a class of single object in Realm?

For example, I need to store info for current user of the app and I would like that info to stored in Realm (similarly to usersdefault, but with some big files). Is it the same as just create a current user singleton in Realm? What is the best practice to achieve that?

Upvotes: 1

Views: 241

Answers (1)

segiddins
segiddins

Reputation: 4120

You could always just create a single user object, or have an isActive property on your user class.

Doing [User allObjectsInRealm:realm].firstObject should then let you fetch the user (presuming you go the single user object route).

Upvotes: 2

Related Questions