You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
This change causes our app to crash on launch.
I believe the change itself is correct, but as stated by Apple’s documentation observer must be retained elsewhere by NSNotificationCenter until the registration is removed.
The reason will be displayed to describe this comment to others. Learn more.
In NSNotificationCenter the observer is not retained and the calling code is responsible for removing it before it is deallocated, so I didn't realise this method was documented to behave differently.
In which case I think the original code was correct, but needs new code to release the observer when it is removed from the notification center.
eg. at the end of -removeObserver:name:object: something like
if ([observer isKindOfClass: [GSNotificationObserver class]) RELEASE(observer);
or some more efficient mechanism.
db90ab6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change causes our app to crash on launch.
I believe the change itself is correct, but as stated by Apple’s documentation
observer
must be retained elsewhere by NSNotificationCenter until the registration is removed.Should this be done here?
libs-base/Source/NSNotificationCenter.m
Line 294 in db90ab6
db90ab6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In NSNotificationCenter the observer is not retained and the calling code is responsible for removing it before it is deallocated, so I didn't realise this method was documented to behave differently.
In which case I think the original code was correct, but needs new code to release the observer when it is removed from the notification center.
eg. at the end of -removeObserver:name:object: something like
if ([observer isKindOfClass: [GSNotificationObserver class]) RELEASE(observer);
or some more efficient mechanism.