"downcast from CLplacemark? to Clplacemark only unwraps optional"(swift2) -


how fix error :

"downcast clplacemark? clplacemark unwraps optional" 

so use code :

if let p = clplacemark(placemark: placemarks.first as? clplacemark){} 

and change placemarks[0] array not work

and code :

clgeocoder().reversegeocodelocation(userlocation) { (placemarks, error) -> void in      if error == nil {         if let p = clplacemark(placemark: placemarks[0] as? clplacemark){              print(p)             self.adsresslabel.text = "\(p.administrativearea)\(p.postalcode)\(p.country)"         }       }else {         print (error)     }       } 

at code :

if let p = clplacemark(placemark: placemarks[0] as? clplacemark) 

i have error

 "downcast clplacemark? clplacemark unwraps optional" 

how fix error ?!

if don't need make copy of first placemark, need :

if let p = placemarks.first {         print(p)         self.adsresslabel.text = "\(p.administrativearea)\(p.postalcode)\(p.country)" } 

on other hand, if need copy:

if let p0 = placemarks.first {          let p = clplacemark(placemark:p0)         print(p)         self.adsresslabel.text = "\(p.administrativearea)\(p.postalcode)\(p.country)" } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -