Skip to content

Instantly share code, notes, and snippets.

View technikyle's full-sized avatar

Kyle Rokita technikyle

  • Ginger Labs
  • San Francisco, CA
View GitHub Profile
@damianesteban
damianesteban / result.swift
Last active November 13, 2016 19:00
Swift 3 updated code with simple examples from this fantastic article: http://alisoftware.github.io/swift/async/error/2016/02/06/async-errors/
// A Gist.
struct Gist {
let id: String
}
typealias JSONDictionary = [String: AnyObject]
// These methods are "helpers" to transform Data -> JSON -> Result<[Gist]>
func jsonFrom(data: Data) -> Result<AnyObject> {
let json = try! JSONSerialization.jsonObject(with: data, options: [])