-2

I am blocked by this nasty error while learning iOS sharedSession singleton and async calls

here is my code

let baseUrl = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecast = NSURL(string: "47.856223,-122.272590", relativeToURL: baseUrl)
let sharedSession = NSURLSession.sharedSession()
let downloadTask: NSURLSessionDownloadTask =
sharedSession.downloadTaskWithURL( forecast, completionHandler:
    { (loction: <#NSURL!#>, response: <#NSURLResponse!#>, error: <#NSError!#>) -> Void in
        println(response);
    })

}

here is where error happens

{ (loction: <#NSURL!#>, response: <#NSURLResponse!#>, error: <#NSError!#>) -> Void in
                println(response);
            })

here is error

1-expected an identifier to name generic parameter
2- expect parameter type following :
codester
  • 36,891
  • 10
  • 74
  • 72
Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221

1 Answers1

1

You need to add placeholders with appropriate variables.Replace your code with following

sharedSession.downloadTaskWithURL(forecast , completionHandler:{(location:NSURL!, response:NSURLResponse!, error:NSError!) -> Void in
    println(response);

 })
codester
  • 36,891
  • 10
  • 74
  • 72