Created
May 9, 2015 22:00
-
-
Save arslanbilal/ca37a81885bcf96f0bc0 to your computer and use it in GitHub Desktop.
Getting JSON Data in the NSDictionary with HTTP GET Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let urlString: String = "http://example.com" | |
var url: NSURL = NSURL(string: urlString)! | |
var data = NSData() | |
var request = NSMutableURLRequest(URL: url, cachePolicy: .UseProtocolCachePolicy, timeoutInterval: 60) | |
request.HTTPMethod = "GET" | |
var response: AutoreleasingUnsafeMutablePointer<NSURLResponse?> = nil | |
var error: NSErrorPointer = nil | |
data = NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)! | |
var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as! NSDictionary | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment