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) Pulling Data From the Web Making a Network Call

Avith Gutierrez
Avith Gutierrez
2,797 Points

App Terminating, need support.

Hey i am having an issue with: 2014-10-09 17:48:35.906 stormY[1879:63421] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:error:]: nil URL argument' this is from the LOG.

This is my code

```import UIKit

class ViewController: UIViewController {

private let apiKey = "7b0e6589397f393a900cd6fc4df61906"



override func viewDidLoad() {

    super.viewDidLoad()

    // Do any additional setup after loading the view, typically from a nib.

    //19.429418, -99.205582"

    let baseURL = NSURL(string:"https://api.forecast.io/forecast/\(apiKey)/")

    let forecastURL = NSURL(string:"19.429418, -99.205582", relativeToURL: baseURL)

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



    println(weatherData)

}



override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()

    // Dispose of any resources that can be recreated.
Any ideas or suggestions?

4 Answers

Stone Preston
Stone Preston
42,016 Points

try removing the space between your coordinates

let forecastURL = NSURL(string:"19.429418,-99.205582", relativeToURL: baseURL)
Kyle Rose
Kyle Rose
7,998 Points

this worked for me. It always amazes me how the simplest thing can make the entire program not function.

Eric Whittaker
Eric Whittaker
2,974 Points

I agree. Worked great stone. Thanks again.

Avith Gutierrez
Avith Gutierrez
2,797 Points

You got it it worked for me :D i have already the data in JSON.

Removing the space was the issue.

Thanks.

I too had to remove the space! Wow! Thanks Stone!

same here ...needed to remove space. Wonder why though? I thought ios didnt care about spaces and should have handled through the core..no?