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 trialDavid Contreras
6,187 PointsExecution was interrupted reason: EXC_BAD_INSTRUCTION
Getting error with these lines of code
private let apiKey = "APIKEYNUMBERS"
let baseUrl = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forcastUrl = NSURL(string: "32.995252, -94.965818", relativeToURL: baseUrl)
let weatherData = NSData.dataWithContentsOfURL (forcastUrl, options: nil, error: nil)
3 Answers
Lukas Herbst
3,451 PointsHey,
had the same error and found it!
The error is that you have a space in the location string!
First I had:
let location = "48.277593, 12.160272"
and the app crashed - but without the space
let location = "48.277593,12.160272"
all worked just fine.
Hope this helped!
Andres Oliva
7,810 PointsTry this line of code:
let dataObject = NSData(contentsOfURL: forcastUrl)
David Contreras
6,187 PointsThe error that I'm getting is on the forcatsUrl. I don't know why this is happening.
Ami Bhimani
6,373 Pointslet forcastURL = NSURL(string: "00.000000, __ -00.000000", relativeToURL: baseURL)
REMOVE SPACE __ and replace to
let forcastURL = NSURL(string: "00.000000,-00.000000", relativeToURL: baseURL)
David Contreras
6,187 PointsDavid Contreras
6,187 PointsI figured it out, thank you for your help.
Bradley Allen
5,224 PointsBradley Allen
5,224 PointsThis is the issue I was having. Pasan said we could copy and past the location data from Google and just copy and pasting it ends up introducing a very hard to spot space in the final "forecastURL".