Created
April 12, 2017 14:16
-
-
Save fadion/0be69887dc1899d6615e0c9f26fa0716 to your computer and use it in GitHub Desktop.
This file contains 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
let realm = try! Realm() | |
let json = JSON(self.data)["pizza"].array | |
let viewModels = json.map { item -> PizzaViewModel in | |
let model = Pizza() | |
model.id = item["id"].intValue | |
model.name = item["name"].stringValue | |
model.price = item["price"].intValue | |
try! realm.write { | |
realm.add(model, update: true) | |
} | |
return PizzaViewModel(model: model) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment