Hello, A few days ago I was having this same issue. The reason KVO doesn't work out-of-the-box with CALayer subclasses, I believe, is because CALayer overrides +automaticallyNotifiesObserversForKey: to return NO. My solution was to override +aNOFK: in my custom subclass to return YES for my custom key. This has worked flawlessly for me - please let me/us know whether it does for you. Here's the applicable code snippet:
+ (BOOL)automaticallyNotifiesObserversForKey: (NSString *)key { /* The NSObject implementation defaults to returning YES to this method. But because we're a CALayer subclass, we have to override it to return YES when key == one of our properties. This is because CALayer overrides the NSObject default functionality, so that this method always returns NO for CALayer and its subclasses. */ if ([key isEqualToString: @"gridShown"]) return YES; return [super automaticallyNotifiesObserversForKey: key]; } (I suppose we could figure out definitively whether CALayer was overriding +aNOFK: by comparing its +aNOFK: IMP with NSObject's +aNOFK: IMP. If I try this I'll get back to the list with my findings...) David _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com