Skip to content

Instantly share code, notes, and snippets.

Created September 12, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7f5b592a3b7816007bdfc86ce479f473 to your computer and use it in GitHub Desktop.
Save anonymous/7f5b592a3b7816007bdfc86ce479f473 to your computer and use it in GitHub Desktop.
if let json = jsonOptional as? Dictionary<String, AnyObject> {
if let id = json["id"] as AnyObject? as? Int { // Currently in beta 5 there is a bug that forces us to cast to AnyObject? first
if let name = json["name"] as AnyObject? as? String {
if let email = json["email"] as AnyObject? as? String {
let user = User(id: id, name: name, email: email)
callback(user)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment