Shmidt
Shmidt

Reputation: 16664

'MKMapItem' is not convertible to 'CLPlacemark'

How can I convert MKMapItem to CLPlacemark in Swift?

My code gives me a compiler error 'MKMapItem' is not convertible to 'CLPlacemark':

var mapItems:[MKMapItem] = []
let mi = self.mapItems[indexPath.row];
ann.placemark = mi as CLPlacemark

In ObjC I just did ann.placemark = (CLPlacemark *)mi;

Upvotes: 2

Views: 1668

Answers (1)

jou
jou

Reputation: 5858

MKMapItem is not a subclass of CLPlacemark. I'm not that familiar with MapKit, so maybe it was indeed possible to directly cast a MKMapItem to a CLPlacemark without problem.

MKMapItem does have a property called placemark with type MKPlacemark though. MKPlacemark is a subclass of CLPlacemark and can be used as such.

Upvotes: 2

Related Questions