So I have created a class that appears as follows:
class ResourceModel: Resource {
var category: Category?
var title: String?
override class var resourceType: ResourceType {
return "resources"
}
override class var fields: [Field] {
return fieldsFromDictionary([
"category": Attribute(),
"title": Attribute()
])
}
init(category: Category?, title: String?) {
self.category = category
self.title = title
super.init()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
required init() {
super.init()
}
enum Category {
case parking_office, parking_cb, conference_room
}
}
When running a findAll on my class, I get this error:
2016-10-10 12:04:19.607 Office App[6057:227184] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Office_App.ResourceModel 0x608000ee8480> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key category.'
When switching my category field to a String for testing, this error goes away.
Is there something I'm doing improperly? How would I go about supporting an enum?
Unfortunately key value coding only works with NSObjects. This is one of the biggest downsides of using Spine. So you have to make your Category type a class.
So I have created a class that appears as follows:
When running a findAll on my class, I get this error:
When switching my category field to a String for testing, this error goes away.
Is there something I'm doing improperly? How would I go about supporting an enum?