Reputation: 171
I am converting my Swift 1.2 project into Swift 2.0, and the biggest error so far is that when using reverseGeocodeLocation(), my CLPlacemarks no longer work. Xcode attempts to unwrap them properly but gets stuck. Here is my code that worked in 1.2:
CLGeocoder().reverseGeocodeLocation(savedLocation, completionHandler: { (placemarks, error) -> Void in
if error != nil {
print(error)
} else {
if let p = CLPlacemark(placemark: (placemarks?[0] as? CLPlacemark))
//The above line is where it's having trouble
{
if p.subThoroughfare != nil {
self.address = "\(p.subThoroughfare) \(p.thoroughfare) \(p.locality) \(p.postalCode)"
self.annotation.subtitle = self.address
}
}
}
})
How can I properly implement them?
Upvotes: -1
Views: 434