Short version
How could I store the value of class instance(for example: MKMapItem) into core data?
Long version:
I need to present/store following info after the user select location:
* <MKMapItem>.name: String
* <MKMapItem>.placemark.title: String
* <MKMapItem>.placemark.coordinate: CLLocationCoordinate2D
In the beginning, I plan to store coordinate, and read other info by
MKPlacemark(coordinate: coordinate). Unfortunately it has never been able to findplacemarkfromcoordinate.Thus, I change my plan to store the whole
MKMapIteminstance. I supposed I can use JSON to encode and store as Binary Data. However, in such way, I need to duplicate the wholeMKMapItemstructure and conform each toCodable.
Thus I wonder if there is a better way to store it ?
- My backup plan is to create an entity to store
name:String, title:String, latitude:Double, longitude: Doublein CoreData, but then I lost the MKMapItem class structure.
But I feel there might be a much better way to do it...
p.s. I started learning iOS Dev from SwiftUI time. Thus I do not have much pre-knowledge for codes in MVC times or earlier.