• 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: overriding a method with NSObject's version
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: overriding a method with NSObject's version


  • Subject: Re: overriding a method with NSObject's version
  • From: Roland King <email@hidden>
  • Date: Sun, 25 Nov 2012 10:36:53 +0800

On 24 Nov, 2012, at 10:23 PM, email@hidden wrote:

>
>
> On 24 Nov 2012, at 09:55, Roland King <email@hidden> wrote:
>
>> I have a fairly well-used and oft-subclassed class which overrides valueForKey: and setValue:ForKey: to behave like the NSDictionary versions, because this class looks much like an NSDictionary. I have a subclass of that which wants to do 'normal' KVO, and so I need valueForKey: and setValueForKey: to return to the default NSObject version.
>>
>> I could use composition but that's a lot of boilerplate to re-expose the properties of the composed class and I really did want it to be a subclass. I could code up a custom valueForKey: which does the right thing, but that's fragile if I add more properties or subclass again. So I want to actually make the implementation of those two methods in my subclass use the NSObject implementation.
>>
>>
>
> Would something like the following be worth considering:
>
> Class A uses custom valueForKey.
> SubClass A1 needs the super implementation.
>
> A:
>
> + (BOOL)useCustomKVO
> {
> 	return YES;
> }
>

That's what I started with and thought, there must be a better way, but there isn't a better way I can find that doesn't involve what's basically swizzling so .. I'm going to go back to that simple, direct, easy-to-understand-and-document version.

Thanks for all the on and off list replies.

_______________________________________________

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

References: 
 >overriding a method with NSObject's version (From: Roland King <email@hidden>)
 >Re: overriding a method with NSObject's version (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: overriding a method with NSObject's version
  • Next by Date: What about QLSeamlessDocumentOpener
  • Previous by thread: Re: overriding a method with NSObject's version
  • Next by thread: What about QLSeamlessDocumentOpener
  • Index(es):
    • Date
    • Thread