• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)


  • Subject: Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)
  • From: Dave Keck <email@hidden>
  • Date: Thu, 21 May 2009 20:12:09 -1000

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 (email@hidden)

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 email@hidden

  • Follow-Ups:
    • Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)
      • From: Kiel Gillard <email@hidden>
References: 
 >Synthesized properties for scalars not KVO compliant (From: Kiel Gillard <email@hidden>)
 >Re: Synthesized properties for scalars not KVO compliant (From: Jerry Krinock <email@hidden>)
 >Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant) (From: Kiel Gillard <email@hidden>)

  • Prev by Date: Re: [Core Data] Difference between objectWithID: and a fetch "self IN %@", someObjectIDs ????
  • Next by Date: Re: Getting other application's window/document name
  • Previous by thread: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)
  • Next by thread: Re: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)
  • Index(es):
    • Date
    • Thread