On Sep 22, 2016, at 03:16 , Gabriel Zachmann <z...@tu-clausthal.de> wrote:
> That makes me wonder: why isn't it possible to register several, different
> observers for the same thing?
> That way, I wouldn't need to care about observations I didn't create, would I?
Because the observer is an object. Your observation and a superclass
observation come from the same object. Whether these are to be treated as
different observations** cannot be determined automatically, hence the need for
The reason it’s messy is that the observer/notification API is old and doesn’t
follow modern API design practices. If this were being designed today, the
“observeValueForKeyPath…” method would likely be replaced by a block/closure
(similar to a completion handler) that’s passed as a parameter to the
“addObserver…” call, and there wouldn’t be any contexts.
** That is, a superclass ‘addObserver’ may be in common code that’s used by all
the subclasses, or it may be a private observation that’s separate from what
subclasses use. Where the observation is created is insufficient to determine
whether it’s an observation “you” created, or you “care about”.
Cocoa-dev mailing list (Cocoafirstname.lastname@example.org)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to arch...@mail-archive.com