Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAsim Zaidi
2,222 PointsError in sharedSession singleton closure
I am following the vide but I am blocked by this nasty error
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 :
2 Answers
Chris Shaw
26,676 PointsHi Asim,
The issue is occurring with the below.
(loction: <#NSURL!#>, response: <#NSURLResponse!#>, error: <#NSError!#>) -> Void in
Why?
Something such as <#NSURL!#>
as it's invalid syntax and not a valid type, instead you want the the following.
(loction: NSURL!, response: NSURLResponse!, error: NSError!) -> Void in
Happy coding!
Asim Zaidi
2,222 Pointsthat worked! thanks