• 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: Detecting reading a key in KVC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting reading a key in KVC


  • Subject: Re: Detecting reading a key in KVC
  • From: Remco Poelstra <email@hidden>
  • Date: Fri, 12 Nov 2010 20:13:33 +0100


Op 12 nov 2010, om 19:16 heeft Quincey Morris het volgende geschreven:
As as been said several times in this thread, you *shouldn't* override 'valueForKey:', but instead override 'valueForUndefinedKey:' like this:

Is this kind of override ok?: valueForKey: { [properties valueForKey:key]; }

Otherwise the valueForKey is called on my wrapper, instead of the dictionary that contains the real keys. I don't see how else the KVC logic should find out about that instance variable.


@implementation PropertiesController - (id) valueForUndefinedKey: (NSString*) key { id retVal=[properties objectForKey:key]; // note: NOT 'valueForKey:' if (!retVal) { //fetch value from network //We do not wait for the value } return retVal; } @end

If you want to know how control reaches this method, read the documentation:

http://developer.apple.com/library/mac/#documentation/Cocoa/ Conceptual/KeyValueCoding/Concepts/SearchImplementation.html#// apple_ref/doc/uid/20000955-CJBBBFFA

Unfortunatly, this does not seem to hold for a NSDictionary. It always returns something instead of calling valueForUndefinedKey:


Regards,

Remco Poelstra

_______________________________________________

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: Detecting reading a key in KVC
      • From: Quincey Morris <email@hidden>
References: 
 >Detecting reading a key in KVC (From: Remco Poelstra <email@hidden>)
 >Re: Detecting reading a key in KVC (From: "email@hidden" <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Quincey Morris <email@hidden>)
 >Re: Detecting reading a key in KVC (From: "email@hidden" <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Quincey Morris <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Remco Poelstra <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Graham Cox <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Remco Poelstra <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Graham Cox <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Ken Thomases <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Graham Cox <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Ken Thomases <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Remco Poelstra <email@hidden>)
 >Re: Detecting reading a key in KVC (From: Quincey Morris <email@hidden>)

  • Prev by Date: Core Data: During Migration, should use Primitive Accessors only?
  • Next by Date: Re: Detecting reading a key in KVC
  • Previous by thread: Re: Detecting reading a key in KVC
  • Next by thread: Re: Detecting reading a key in KVC
  • Index(es):
    • Date
    • Thread