2

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;

Shmidt
  • 16,436
  • 18
  • 88
  • 136

1 Answers1

2

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.

jou
  • 5,824
  • 3
  • 22
  • 24