0
@IBOutlet weak var textfield1: UITextField!

@IBOutlet weak var outputlbl: UILabel!

@IBAction func findtheweather(sender: UIButton) {


let url = NSURL(string: "http://www.weather-forecast.com/locations/" + textfield1.text! + "/forecasts/latest")!

So the let url is my url and i'm concatenating my text field in the url so we can get the data for the city the user typed in. But when I do that I get a crash and I get - fatal error: unexpectedly found nil while unwrapping an Optional value (lldb).

I have a picture of my code. I have a picture of my code.

this is my log after the crash this is my log after the crash

Help would be much appreciated.

thanks

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Nareg. C
  • 21
  • 1
  • 5
  • 1
    Either (a) `textField` outlet is not hooked up properly; (b) its `text` property was `nil` (unlikely); or (c) the text included characters that couldn't be properly included in URL (e.g. a space character or something like that. – Rob Jun 17 '16 at 16:43
  • @Nareg. C: Please post your code & errors in text form. Your screenshots look too small on this page and take up more space in my browser cache than the text form. –  Jun 17 '16 at 16:48

0 Answers0