MyLocations Page 180

In the statement:

if let placemark = location.placemark {

I could only get this to work with:

if let placemark = location.placemark as! CLPlacemark?

Did I make a mistake somewhere?

What version of Xcode are you using? It appears that you’re using an older version of Xcode with the latest version of the book. The Swift language has changed a bit in the latest Xcodes, so you need to use Xcode 7.2 or later or the code from the book won’t work.

7.3. But I also downloaded and reinstalled. It now recommends:

if place mark = location.placemark as? CLPlacemark.

But your final project version without the “as? CLPlacemark” runs fine. So let’s not worry about this. XCODE seems to have all kinds of bugs throughout. Sometimes if I just retype something in the editor the behavior goes back to what is expected.