AssociatedValues
AssociatedValues copied to clipboard
How does `key` pointer address remain the same between get/set calls?
A noob question may be.
Following up on your example:
var identifier: String {
get {
return getAssociatedValue(key: "identifier", object: self, initialValue: "Unknown")
}
set {
set(associatedValue: newValue, key: "identifier", object: self)
}
}
"identifier" in both get
and set
should have different memory addresses since they are two different objects. So how is it able to retrieve the previously stored value?