I'm getting errors on the following lines...
let taskData = session.dataTaskWithRequest(request, completionHandler: { ( data: NSData!, reponse:NSURLResponse!, error: NSError!) -> Void in
let parsedStores = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &parseError) as! NSDictionary
if let stores: AnyObjec = parsedStores["Stores"]
This code would work for me on IOS8, I converted the syntax to the latest Swift Syntax and it left me with these errors, I've tried to specifically target the area of the errors on the Syntax editor, but it still doesn't fix it. Please help me get rid of these. Thanks
Code for the function.
func loadRecords()
{
let urlString = "http://google.com"
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config, delegate: nil, delegateQueue: nil)
//Create the URL Object
if let url = NSURL(string: urlString)
{
// Create the request object
let request = NSURLRequest(URL: url)
// execute the request
let taskData = session.dataTaskWithRequest(request, completionHandler: { ( data: NSData!, reponse:NSURLResponse!, error: NSError!) -> Void in
// Do something with the data back
if (data != nil)
{
//get some data back
print("\(data)")
var parseError:NSError?
let parsedStores = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &parseError) as! NSDictionary
println("JSON Data \n \(parsedStores)")
if let stores: AnyObjec = parsedStores["Stores"]
{
self.parseJSON(stores)
}
} else
{ //we got an error
print("Error getting stores: \(error.localizedDescription)")
}
})
taskData.resume()