Say we have a given Swift class.
class Test {
init() {
NotificationCenter.default.addObserver( ... )
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
In a class, you can use the deinit lifecycle method to remove the NotificationCenter observer. In a struct, there is no deinit method. My question is therefore, where would someone remove the NotificationCenter observer in a struct? Or possibly, do we not have to remove the observer in a struct?