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

iOS Build a Weather App with Swift (Retired) Concurrency Writing Concurrent Networking Code

Ilya Feynberg
Ilya Feynberg
2,567 Points

Not able to get the data from the API

let downloadtask: NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(forecastUrl, completionHandler: { (location: NSURL!, response: NSURLResponse!, error: NSError!) -> Void in
            println(response)
            println(error)
        })

This is the code I have . I have trouble getting the response. This is the error I see. Can anyone help me on this?

Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0x7f9721d4e960 {NSErrorFailingURLStringKey=https://api.forecast.io/forecast/e58f3cd2d60744698db7a970c711badb/37.8267,-122.423, NSErrorFailingURLKey=https://api.forecast.io/forecast/e58f3cd2d60744698db7a970c711badb/37.8267,-122.423, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x7f9721c19190 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"}

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Ilya,

Have a read of the below thread, another user had the same issue you're currently having.

https://teamtreehouse.com/forum/concurrency-and-forecast-api-request-connection-lost