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

Weather app with Swift isn't working

    private let apiKey = "b395785aa5895487f309c052b747be89"

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        //"43.645768, -116.340039"
        let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)")
     let forecastURL = NSURL(string: "43.645768, -116.340039", relativeToURL: baseURL)

     let weatherData = NSData.dataWithContentsOfURL(forecastURL, options: nil, error: nil)
        println(weatherData)

I have looked over this multiple times and from what I see my code to exactly the same as the teachers. I haven't touched any of the setting and I've gone over the video multiple time. If I try to run the program it runs successful but sends me to the app.delegate.swift page and sends me this highlighted

class AppDelegate: UIResponder, UIApplicationDelegate { Thread 1: signal SIGABRT

1 Answer

Hello Christian,

I took the code you have, messed around with it and came up with this that worked,

private let apiKey = "b395785aa5895487f309c052b747be89"

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

so try this out and let me know if it works for you too :).

P.S. whenever you're posting an API key don't use your actually API key because this is to be kept a secret, but then again this is just a demo app so it doesn't matter much.

Hope this helps, Kai

the space in my longitude and latitude was giving me the error. Thanks for the help.