Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created June 15, 2015 00:26
Show Gist options
  • Save joshdholtz/747bb59f28d7ce7c8c0e to your computer and use it in GitHub Desktop.
Save joshdholtz/747bb59f28d7ce7c8c0e to your computer and use it in GitHub Desktop.
OMG, protocol extensions for Harmonic
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