Skip to content

Instantly share code, notes, and snippets.

@aGupieWare
Created November 17, 2014 03:18
Show Gist options
  • Select an option

  • Save aGupieWare/971e75181aa61a33371f to your computer and use it in GitHub Desktop.

Select an option

Save aGupieWare/971e75181aa61a33371f to your computer and use it in GitHub Desktop.
Swift client, request item . . .
let task = self.urlSession.dataTaskWithURL(endPointURL!, completionHandler: { (data, response, error) -> Void in
// convert the JSON response data into a NSDictionary //
var jsonParseError: NSError?
var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &jsonParseError)
as NSDictionary
var rawInventoryItems = jsonResult["data"] as Dictionary<String,String>
dispatch_async(dispatch_get_main_queue()!, { () -> Void in
// call our completion handler //
responseHandler( error: nil, itemDescription: rawInventoryItems["description"])
})
})
task.resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment