Basically I am trying to implement a class for a Person and Person's pets. In it's very simple form Person class and Pet class would be like this:
class Person {
var email : String!
var name : String!
var pets : [Pet]!
init(userName: String) {
email = userName
// load Person from CloudKit database
}
}
class Pet {
var name : String!
var breed : String?
}
Now I want to be able to load all Pets related to the specific userName. If I have the above the class, that only holds one Pet. If I do an array like in the Person class, there is no Load method. The question is, should I create a new class Pets like below:
class Pets {
var userName : String
var pets : [Pet]
init(email: String) {
// load all pets related to user here
}
}
Does this make sense? Or is there a better way to structure the class? Is my question clear enough? Thanks for any help in advance.