Created
July 31, 2015 16:45
-
-
Save haranicle/30a19a8836776a0a1b3e to your computer and use it in GitHub Desktop.
??? #CodePiece
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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