Krishna Manda Krishna Manda - 4 months ago 19x
iOS Question

Initializer For Conditional Binding Must Have Optional Type, not CLPlacemark

Noob programmer here.

I'm trying to become a good programmer with the help of the internet. So, I subscribed to Rob Percivals iOS class. I'm having trouble with this bit of my code. Must've been a recent update that's making it fail on my system although it is the same code as his.

CLGeocoder().reverseGeocodeLocation(userLocation) { (placemarks, error) in

if (error != nil) {


} else {

if let p = CLPlacemark(placemark: placemarks![0] as! CLPlacemark) {



Please try to put it in baby english if possible guys. Thanks!


placemarks is of type [CLPlacemark]?. Therefore you should try something like the following:

if let placemarks = placemarks {
    if let p0 = placemarks.first {
        print (p0)

Don't use !. Use if let instead.