Currently I have a class called Place defined as follows:
class Place {
let name: String
let address: String
let coordinate: CLLocationCoordinate2D
let type: String
var photoReference: String?
var photo: UIImage?
/* functions etc */
}
In my data model, I have an entity, called FoundPlaces. It has one attribute, place
, of type "transformable."
I am going insane trying to find the Swift solution to storing this object. Is the data model to begin with wrong?
Any guidance appreciated. Thanks!
The object stored in the transformable attribute needs to implement the
NSCoding
protocol (init(coder:)
andencodeWithCoder:
).The simplest way is to have the
Place
class inherit fromNSObject
and implement the methods above.