• 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: KVC-compliance using -respondsToSelector:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC-compliance using -respondsToSelector:


  • Subject: Re: KVC-compliance using -respondsToSelector:
  • From: Brent Gulanowski <email@hidden>
  • Date: Mon, 19 Jul 2004 10:29:40 -0400

On Sun, 18 Jul 2004 13:32:50 -0400, Brent Gulanowski
<email@hidden> wrote:
>
>
> On Sat, 17 Jul 2004 21:31:46 +0200, Allan Odgaard <email@hidden> wrote:
> > On 17. Jul 2004, at 8:48, Brent Gulanowski wrote:
> >
> > > I'm wrapping another class which can have varying properties. [...]
> > > What other kinds of problems could happen and can they be fixed? [...]
> >
> > I think the best way to handle this is to implement setValue:forKey: in
> > the class which wraps the actual object.
> >
> > You can then selectively forward this to the wrapped object, and
> > setValue:forKey: will be smart enough to call set<Key>: on the wrapped
> > object, if such method exists.
> >
> > For more info see:
> > <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
> > ObjC_classic/Protocols/NSKeyValueCoding.html#//apple_ref/doc/uid/
> > 20000471/BABEHECF>
> >
> >
>
> OK. Although instead of "implement" I guess you meant "override". But
> I've not seen any information on how to override those (and I never
> thought of it, so thanks for the suggestion).
>
> I just need to make sure that it's fine to do my own little test on
> the attribute name and if it fails just call super's implementation.
> Sounds like that would work fine, though.

In fact, the proper strategy is to override -setValue:forUndefinedKey:.

--

Brent Gulanowski
http://www.boredastronaut.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >KVC-compliance using -respondsToSelector: (From: Brent Gulanowski <email@hidden>)
 >Re: KVC-compliance using -respondsToSelector: (From: Allan Odgaard <email@hidden>)
 >Re: KVC-compliance using -respondsToSelector: (From: Brent Gulanowski <email@hidden>)

  • Prev by Date: Re: Obj-C header-file becoming C header-file, & NSImage problem
  • Next by Date: -get<Key>:range:
  • Previous by thread: Re: KVC-compliance using -respondsToSelector:
  • Next by thread: NSValueTransformer - Object Reference
  • Index(es):
    • Date
    • Thread