Hi guys
I'm stumbling over the MVC concept once more. I'm building something simple. I have several animals which I'm showing one by one.
At the moment the array of animals is in the Controller. I suppose it shouldn't be in the Controller but in the Model? Is this so?
Secondly. If the array ought to be in the Model what should I do? Should I use a different struct to define what an Animal is. Or should the array of animals be in the class containing the logic to add animals etc?
So in code I'm in doubt if I should do this:
or
I presume the latter as with the first solution the array would contain for each animal the array animals once more.
Thanks once again
I'm stumbling over the MVC concept once more. I'm building something simple. I have several animals which I'm showing one by one.
At the moment the array of animals is in the Controller. I suppose it shouldn't be in the Controller but in the Model? Is this so?
Secondly. If the array ought to be in the Model what should I do? Should I use a different struct to define what an Animal is. Or should the array of animals be in the class containing the logic to add animals etc?
So in code I'm in doubt if I should do this:
Code:
struct Animal {
var name: String = ""
var birthPlace: String = ""
var breed: String = ""
var age: Double = 0.00
var animals: [Animal] = []
func addAnimal(){}
}
or
Code:
struct Animal {
var name: String = ""
var birthPlace: String = ""
var breed: String = ""
var age: Double = 0.00
}
class animalLogic(){
var animals: [Animal] = []
func addAnimal(){}
}
I presume the latter as with the first solution the array would contain for each animal the array animals once more.
Thanks once again