Search code examples
objective-cmapkitmkannotationmkmapitem

MKAnnotation or MKMapItem


What's the difference between MKAnnotation and MKMapItem?

Which one to use when I want to display some interesting places on my map?
I have a list of objects that have latitude, longitude, title, description and photo so far and I'd like to have them on my map.


Solution

  • MKAnnotation is a MARKER meant for displaying stuff using a MKAnnotationView

    so the procedure is:

    1. add a MKAnnotation to let the map know that there is an entry
    2. wait for the map's delegate call viewForAnnotation
    3. set up a annotationView there that is to be shown

    a good tutorial (IMO) that shows this with detailed code is at: http://www.codigator.com/tutorials/mapkit-tutorial-for-ios-beginners/


    MKMapItem is only for the openMapWithItem api that opens the external app!


    EDIT: MKMapItem has a placemark property which is a MKAnnotation - so if that's non-nil you can add it. (note that it might be nil)