How to remove an observer for NSNotification in a UIView?
- by sudo rm -rf
Hello!
I've added an observer in a custom UIView I've created under initWithFrame:.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateZipFromLocation:)
name:@"zipFoundFromLocation"
object:nil];
The problem is, this view is a subview. When the view is loaded again, it calls the initWithFrame message again, thus adding two observers and so on. How can I remove the observer when the view is going to disappear? Since it is a UIView, it says that viewWillDisappear:(BOOL)animated is not a valid method. Any ideas?