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

Ludwing Najera
Ludwing Najera
4,596 Points

IOS simulator crash: is little snitch the culprit? (little snitch is network monitor)

I was running the IOS simulator when little snitch started asking me about connections. i allowed them all and the app crashed. not a problem. i reopened the app then it started up and crashed with a fatal error on this line of code:

let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)    

does little snitch do anything to the IOS simulator?

the console also said: fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

7 Answers

If the app previously ran OK it may be worth turning off the network monitor and trying again. Also, closing Xcode & the simulator and restarting them often clears some weird crashes.

Alternatively, try adding an "exception breakpoint" as that'll provide you with some more information although the debugger is not massively helpful!

Looking at your error, it sounds like the engine got a nil when it didn't expect one. Does your code check for a network connection before proceeding? Are the nil entries in your line correct?

Ludwing Najera
Ludwing Najera
4,596 Points

well in the teachers notes the teacher said to change and old line of code into what you see on my question. the old one looked like this:

NSData.dataWithContentsOfURL(forecastURL, options: nil, error: nil)

it said due to changes to xcode make it look like what is in my question

With the exclamation mark? That looks odd!

Else, try a restart of Xcode and/or post the exception breakpoint messages.

Steve.

ForecastURL!, I mean ...

Ludwing Najera
Ludwing Najera
4,596 Points

it says on the exeption EXC_BAD_INSTRUCTION

Hi,

What have you tried out? There were a few suggestions:

  1. Close Xcode & restart it
  2. Try running without the network monitor
  3. Check the variable should be called forecastURL! as the exclamation mark looks odd
  4. Put an exception breakpoint in to get more details

Did you try these and did they make any progress?

If not, can you zip your project and post a link to it on here?

Steve.

Ludwing Najera
Ludwing Najera
4,596 Points

how do i link my project

No idea - zip it and send it to me ... steve.hunter@bigdogconsultants.co.uk

I'll have a look tomorrow to see if I can figure out the problem.

Joseph Kandi
Joseph Kandi
2,640 Points

Can you post the value of your forecastURL