andymatuschak/TestMigration — Issue #39: Unnecessary unregisterAsObserver
Author: andymatuschak
Created: 2011-10-23 16:36:30+00:00
State: open
Labels: Migrated

***Andy Matuschak (andymatuschak)** [reported (on Launchpad)](https://bugs.launchpad.net/sparkle/+bug/462120) on' 2009-10-27:*

"It is -unregisterAsObserver that is causing the NSException.

Andy, many of us have a breakpoint set for NSException (and/or
objc_exception_throw) in XCode. So every time we run the app and get to
the point of the second nib instance it causes the breakpoint to fire
and stop execution. This gets rather annoying after a while. :)

I solved this by adding a flag to SUUpdater called
hasRegisteredObservers. I set it in -registerAsObserver and in
-unregisterAsObserver if it is not set it returns.

No more unnecessary NSExceptions."

Hofman: "I wonder if it's not the -unregisterAsObserver in -[SUUpdater
dealloc]. That's potentially dangerous and moreover totally unnecessary,
because instances that did register as observer will never be
deallocated (as they're retained by the sharedUpdaters dictionary),
while instances that are deallocated are never initialized (and
therefore never registered)."