iosmapkitparse-platformmkmapitem

Adding custom objects to a Parse backend iOS


I am building an application that stores locations in a list and later maps them.

The problem I'm running into is an inability to save MKMapItems to a Parse database. I need to save these MKMapItems because they are the only unique identifiers for locations on a map that would not require searching the map again (ex.location name, ex. address).

So my question is, how can I save an MKMapItem to a Parse database?

And to follow up, if it is not possible to save an MKMapItem, how else can I save these items to a map so that I do not have to re-search?

MKMapItem: https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapItem_class/Reference/Reference.html

Parse: https://www.parse.com/docs/ios_guide#top/iOS

EDIT

Another detail that might help: I'm using this to store information about particular venues. For example restaurants. I don't necessarily want to be creating a new map annotations at that mark if I can avoid it.


Solution

  • I'm not sure if Parse has prebuilt support for it, but you can definitely create your own class to do it:

    1) You can create an MKMapItem from an MKPlacemark, using this init method

    - (id)initWithPlacemark:(MKPlacemark *)placemark
    

    2) MKPlacemark is basically just a coordindate and address, created using this init method

    - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
    

    CLLocationCoordinate2D can easily be stored in a custom class on Parse. If you care, you can also store the relevant address values too.

    3) When you need to fetch MKMapItems, you actually fetch the underlying MKPlacemark coordinates, create MKPlacemarks, and finally create MKMapItems using each.