Skip to content

Instantly share code, notes, and snippets.

@haranicle
Created July 31, 2015 16:45
Show Gist options
  • Save haranicle/30a19a8836776a0a1b3e to your computer and use it in GitHub Desktop.
Save haranicle/30a19a8836776a0a1b3e to your computer and use it in GitHub Desktop.
??? #CodePiece
Realm().write {
Realm().deleteAll()
}
let turtle = Animal()
turtle.name = "Turtle"
turtle.legCount = 4
Realm().write {
Realm().add(turtle)
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), { () -> Void in
let realm = Realm()
let crane = Animal()
crane.name = "Crane"
crane.legCount = 2
NSThread.sleepForTimeInterval(1)
Realm().write {
Realm().add(crane)
}
println("---added")
let animals2 = Realm().objects(Animal)
for animal in animals2 {
println(animal.name)
}
})
let animals1 = Realm().objects(Animal)
for animal in animals1 {
println(animal.name)
}
NSThread.sleepForTimeInterval(2)
println("---result")
let animals3 = Realm().objects(Animal)
for animal in animals3 {
println(animal.name)
}
//Turtle
//---added
//Turtle
//Crane
//---result
//Turtle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment