On Nov 10, 2010, at 05:58, jonat...@mugginsoft.com wrote: > On 10 Nov 2010, at 12:47, Remco Poelstra wrote: > >> Hi, >> >> I've an object which properties I access via key-value coding. These >> properties are sometimes "uninitialized" (that means, the real value needs >> to be read from the Wifi network). I would like to detect a read of such >> property and then fetch it from the network. It's not a problem that in the >> mean time a "wrong" value is returned. How can I detect a read of a property? >> >> Kind regards, >> >> Remco Poelstra >> >> > > Try overriding your objects -valueForKey: and -valueForKeyPath: > NSKeyValueCoding is implemented as a category on NSObject so will be > available on your object.
Unless I'm missing something, that isn't necessary. The OP just needs to write a getter for the property. For a property "abc", he'd do something like this: // @synthesize abc; (don't need this any more) - (NSString*) abc { if (... we already fetched the value from the network ...) return ... the correct value ... else { ... start the network access ... return ... a temporary value ... } } That works even if the value is accessed via [... valueForKey: @"abc"], because the default implementation in NSObject will call the getter 'abc' if it exists. _______________________________________________ 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