I have a question about NSURLSession
I have downloaded JSON
data using NSURLSession
I want to access the JSON enter code here
Data variable from outside this block of code so I manipulate it
this is my code
// variable declared in my class
var jsonData = JSON("")
// my function
func loadCategories(){
var url = NSURL(string: "http://localhost:8888/api/v1/getAllCategories")
var request = NSMutableURLRequest(URL:url!)
request.HTTPMethod = "GET"
NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data: NSData!, response: NSURLResponse!, errors: NSError!) in
self.jsonData = JSON(data: data)
}).resume()
}
When I try to get jsonData outside the block of NSURLSession
I get empty variable
Any help ?