I was fumbling around with an own class. I tried to let the class keep an array of all objects created with that class. For instance
This doesn't work though? Or is it a no go to enter an array of its owns objects within the class?
Code:
class Wife {
var id: UInt
var existingWives:[Wife]?
init(){
if let _ = self.existingWives {
self.id = UInt(self.existingWives!.count) + 1
self.existingWives!.append(self)
} else {
self.id = 1
self.existingWives = [self]
}
}
}