When I searched on here I now know that almost everything in Swift is value based, not referenced base. I also have read that a class holds references. I tried my best, but below code will not print anything. If anyone could help me out printing out that line with the help of an array, that would be great :) (if it is possible ofcourse...).
Edit: I want 5 booleans in the array, in which they all have a didSet method. When I access them, that specific didSet will trigger. Is that possible?
class PowerUpBooleans{
var boolean: Bool
init(boolean: Bool){
self.boolean = boolean
}
}
var iWantToChangeThis = false{
didSet{
print("it worked")
}
}
var powerUpBooleans = [PowerUpBooleans]()
override func viewDidLoad() {
super.viewDidLoad()
powerUpBooleans.append(PowerUpBooleans(boolean: iWantToChangeThis))
powerUpBooleans[0].boolean = true
}