Thomas Schnitzer
2000-09-04 12:57:25 UTC
Hi all,
in the AppKit, delegate methods are often balanced by notification messages and the delegate is said to receive all notifications. Does this mean
1 - the delegate is added as a notification receiver to [NSNotificationCenter defaultCenter] for all delegate methods it implements in the -setDelegate: method (convenient) or
2 - after each and every notification the object posts the delegate is queried whether it implements the related method and if so, this method is invoked (cumbersome).
My problem with (1): the delegate would have to call [NSNotificationCenter removeObserver:self] in its implementation of -dealloc, that is, the delegate would have to take care of a detail of the implementation of the delegated object. (Weak) solution: the delegate is supposed to exists at least as long as the delegated object exists (the delegate isn't retained)?
What's the "right" solution?
Thanks in advance
Thomas
in the AppKit, delegate methods are often balanced by notification messages and the delegate is said to receive all notifications. Does this mean
1 - the delegate is added as a notification receiver to [NSNotificationCenter defaultCenter] for all delegate methods it implements in the -setDelegate: method (convenient) or
2 - after each and every notification the object posts the delegate is queried whether it implements the related method and if so, this method is invoked (cumbersome).
My problem with (1): the delegate would have to call [NSNotificationCenter removeObserver:self] in its implementation of -dealloc, that is, the delegate would have to take care of a detail of the implementation of the delegated object. (Weak) solution: the delegate is supposed to exists at least as long as the delegated object exists (the delegate isn't retained)?
What's the "right" solution?
Thanks in advance
Thomas