Skip to content

Instantly share code, notes, and snippets.

@nunogoncalves
Created January 6, 2016 14:48
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 nunogoncalves/170008e85617e3eb9bac to your computer and use it in GitHub Desktop.
Save nunogoncalves/170008e85617e3eb9bac to your computer and use it in GitHub Desktop.
struct Languages {
func get(success success: [Language] -> (),
failure: NetworkStatus -> ()) {
let qos = Int(QOS_CLASS_USER_INTERACTIVE.rawValue)
dispatch_async(dispatch_get_global_queue(qos, 0)) {
let responseHandler = ResponseHandler()
responseHandler.failureCallback = { status in
dispatch_async(dispatch_get_main_queue()) {
failure(status)
}
}
responseHandler.successCallback = { dictionary in
let languages = extractLanguagesFrom(dictionary)
dispatch_async(dispatch_get_main_queue()) {
success(languages)
}
}
Network.Requester(networkResponseHandler: responseHandler).makeGet("http://some_languages_website.com")
}
}
private func extractLanguagesFrom(dictionary: NSDictionary) -> [Languages] {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment