I'm trying to make an Action Extension for my app where the user can add his current location along with some other data. I debugged the extension after sharing a location with Apple Maps App and found out that Maps sends four providers with following content:
- a vCard of selected location
- an Apple Maps URL for selected location
- a plain text which is the name of selected location
- a
MKMapItem
All of the content above is in type of NSSecureCoding
. Force cast to Data
and initialising String
with that data for vCard, to String
for plain text and url succeed from NSSecureCoding, but I haven't found a way to create a MKMapItem
object from the Data I receive.
Here's what I tried:
provider.loadItem(forTypeIdentifier: "com.apple.mapkit.map-item", options: nil) { (content, _) in
let item = content as! MKMapItem
}
but it fails. I probably have to cast it to Data
first but I couldn't find any initialiser for MKMapItem
with Data