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 trial


Stefanie D'Angelo
Stefanie D'Angelo
Courses Plus Student 4,431 Points

downloadTaskWithURL gives compiler error!

downloadTask in the Weather app gives me compiler error and I don't get what I've done wrong. I have typed in the code exactly like the video.

'override func viewDidLoad() {
    // Do any additional setup after loading the view, typically from a nib.

    let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
    let forecastURL = NSURL(string: "59.307469,18.075581", relativeToURL: baseURL)

    let sharedSession = NSURLSession.sharedSession()

    let downloadTask: NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(forecastURL, completionHandler: { (location: <#NSURL!#>, response: <#NSURLResponse!#>, error: <#NSError!#>) -> Void in
        println(response, error)


When I try to run this code it gives me the compiler error "Expected an identifier to name generic parameter" and "Expected parameter type following :" and points at the downloadTask-section. What have I done wrong?

If you said your code is exact same as in video, I had the same thing last night to I just deleted it all and pasted the code that teacher wrote and then I looked whats wrong but it was the same, I guess its the way the " gets or something don't know.

Stefanie D'Angelo
Stefanie D'Angelo
Courses Plus Student 4,431 Points

Thank you for your advice!! It solved the problem immediately!

Sometimes when I was in CSS, I wrote exactly the same code but it didn't worked I think its " as I looked so I rewrote it and it was okay , its just that " set up in different way as I saw from my experience.

Glad I could help ^^

1 Answer

It looks like a similar issue was solved here.


In my case, I was getting the error and NSURL!, NSURLResponse!,and NSError! were highlighted in dark blue. I was able to double-click each of the and XCode was satisfied. I am thinking it has something to do with highlighting the entire completionHandler singleton and hitting ENTER to let XCode fill it out.

Running XCode 6.1.1