Skip to content

Instantly share code, notes, and snippets.

@ennioma
Last active July 6, 2017 22:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ennioma/47831dadd59d27f9644abab0ca65fc11 to your computer and use it in GitHub Desktop.
import RealmSwift
// Define your models like regular Swift classes
class Dog: Object {
dynamic var name = ""
dynamic var age = 0
}
// Use them like regular Swift objects
let myDog = Dog()
myDog.name = "Rex"
myDog.age = 1
print("name of dog: \(myDog.name)")
// Get the default Realm
let realm = try! Realm()
// Persist your data easily
try! realm.write {
realm.add(myDog)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment