Quantcast
Viewing all articles
Browse latest Browse all 39

Answer by kubi for '[CLPlacemark]?' is not convertible to '[CLPlacemark]' -> swift2

In Xcode 7.0, Objective-C has generic arrays, so your placemarks array is no longer [AnyObject]? but is now [CLLocation]?. You don't need to cast the array, you can just unwrap the optional. With the addition of guard statements, your completion block is now as simple as:

geocoder.reverseGeocodeLocation(location) { placemarks, error in    guard let placemarks = placemarks else { print(error); return; }    guard let placemark = placemarks.first else { return; }    // ...}

Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>