Created
June 15, 2015 00:26
-
-
Save joshdholtz/747bb59f28d7ce7c8c0e to your computer and use it in GitHub Desktop.
OMG, protocol extensions for Harmonic
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
var json : Dictionary<String, AnyObject> = ["first_name" : "Josh", "last_name" : "Holtz", | |
"best_friend" : ["first_name" : "Bandit", "last_name" : "The Cat"], | |
"friends" : [ ["first_name" : "Red Ranger"], ["first_name" : "Green Ranger"] ], | |
"birthday" : "1989-03-01" | |
] | |
var jsons = [json] | |
/* | |
* OLD WAY (before protocol extensions) | |
*/ | |
// Single model | |
var user = HarmonicModelMaker<UserNonRestModel>().createModel(json) | |
// Collection of model | |
var users = HarmonicModelMaker<UserNonRestModel>().createCollection(jsons) | |
/* | |
* NEW WAY (with protocol extensions) | |
*/ | |
// Single model | |
var user = UserModel.parse(json) | |
// Collection of model | |
var users = UserModel.parse(json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment