Closed jarredszabadi closed 7 years ago
Your keys in the fieldsFromDictionary
method are not set up correctly. The keys there must correspond to the name of variable in the Swift class. Then if you want to use a different name in the JSON, use the serializeAs(name: String)
method. So for the Equipment
class:
override class var fields: [Field] {
return fieldsFromDictionary([
"modelNumber": Attribute(),
"serialNumber": Attribute(),
"gym": ToOneRelationship(Gym).serializeAs("location"),
"devices": ToManyRelationship(Device)
])
}
Hello,
Looking for some help as I get started using spine. Specifically the problem is setting up a relationship between two classes as well as understanding the correct way to name my fields to match with those in the api endpoint.
In this situation the endpoint has:
My problem is that I'm receiving "class is not key value coding-compliant" at different places in the code and setting attributes for the three classes (Gym, Equipment, Device) are throwing undefinedKey errors.
Issue 1: All the attributes in the objects throw `setValue:forUndefinedKey:]: this class is not key value coding-compliant
Issue 2: The arrays which hold the equipment and devices throw the same error.
Here's a snip of the json and the three class models.
class Gym: Resource {
class Equipment: Resource {
class Device: Resource {
## JSON SNIPPET (Pardon the formatting issues)
{
"data": {
}, "included": [ {
] }
## Code To Parse JSON
`func spineGetTestGym(){