didSet and willSet are a pair of stored property observers for class or struct. How about the stored property itself is a class or struct? Does changing a stored property of didSet/willSet bound story property triggers didSet/willSet? Clear example:
class Cat {
var name: String!
}
struct Dog {
var name: String!
}
struct Host {
var cat: Cat! {
didSet {
print("Set a 😼")
}
}
var dog: Dog! {
didSet {
print("Set a 🐶")
}
}
}
var host = Host()
host.cat = Cat() //Set a 😼
host.dog = Dog() // Set a 🐶
host.cat.name = "Cat"
host.dog.name = "Dog" // Set a 🐶
Quick wrap-up, updating any property of dog (struct) is actually creating a new dog instance and assigning it to Host, because it is a constant stored property of Host. For cat (class) in Host, it's mutable so that didSet wasn't triggered.