MYLocation p173 func configure()

Hi all,
I m following tutorial 3 v5 and I have an “Thread1: EXC_Bad” error message when I run the app.
Could someone help me to fix it ?

this is the code:

func configure(for location: Location) {
if location.locationDescription.isEmpty {
descriptionLabel.text = “(No Description)”
} else {
descriptionLabel.text = location.locationDescription
}

	if let placemark = location.placemark {
		var text = ""
		if let s = placemark.subThoroughfare {
			text += s + " "
		}
		if let s = placemark.thoroughfare {
			text += s + ", "
		}
		if let s = placemark.locality {
			text += s
		}
		addressLabel.text = text
	} else {
		addressLabel.text = String(format:
			"Lat: %.8f, Long: %.8f", location.latitude, location.longitude)
	}
}

What’s the line on which you get the crash?

Also, sharing a download link to your project is the easiest way to get help with a crash since then anybody interested can download it and experience the crash for themselves and then be able to help you faster :slight_smile:

Fahim, thank u for your answer.

  1. the crash is at this level “descriptionLabel.text = location.locationDescription”
  2. how can I do a download link to my project?

Thx.

Patrick

The most likely culprit would be that you forgot to connect descriptionLabel to its outlet in the storyboard. Check the storyboard to see if you’ve correctly connected the label to its outlet.

If that is correct, then probably uploading a copy of your project somewhere (like DropBox) and then providing a link to that so others can download it and try out the code might help. Simply copy the whole project folder to DropBox, or ZIP up the project folder and then upload the ZIP file to DropBox. Then you can get a link from DropBox that you can share with others. There are also other services besides DropBox which would allow you to do essentially the same thing :slight_smile:

This topic was automatically closed after 166 days. New replies are no longer allowed.