discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC


From: Chris Farber
Subject: Re: KVC
Date: Tue, 29 May 2007 13:15:30 -0400

Helge,

In Apple's documentation for setValue:forKey:, they have this under compatibility notes:

For backward binary compatibility with takeValue:forKey:'s behavior, a method whose name matches the pattern -_set<Key>: is also recognized in step 1. Note that KVC accessor methods whose names start with underscores are deprecated as of Mac OS X v10.3.

For backward binary compatibility, unableToSetNilForKey: will be invoked instead of setNilValueForKey: in step 1, if the implementation of unableToSetNilForKey: in the receiver's class is not NSObject's.

The behavior described in step 2 is different from takeValue:forKey:'s, in which the instance variable search order is <key>, _<key>.

For backward binary compatibility with the behavior of takeValue:forKey:, handleTakeValue:forUnboundKey: will be invoked instead of valueForUndefinedKey: in step 3 if the implementation of handleTakeValue:forUnboundKey: in the receiver's class is not NSObject's.


Is this what you are referring to?

Chris

On May 29, 2007, at 5:31 AM, Helge Hess wrote:

On May 29, 2007, at 11:17, Richard Frith-Macdonald wrote:
Hi Helge, It's not clear to me what the problem is with - setNilValueForKey:

The Apple documentation at http://developer.apple.com/ documentation/Cocoa/Reference/Foundation/Protocols/ NSKeyValueCoding_Protocol/Reference/Reference.html#//apple_ref/occ/ instm/NSObject/setNilValueForKey: says that 'The default implementation raises an NSInvalidArgumentException'

Are you saying that the Apple implementation does not do what the documentation says?

Well, I don't have the time to properly reproduce the exact issues, but I think Cocoa has a Compatibility mode for classes which do implement -takeValue:forKey:.
Which also involves (overrides) -setNilValueForKey:.

I assume the documentation is correct if you use new-style KVC, but for old-style code (probably the far majority of existing code!) an possibly undocumented Compat mode kicks in.

Greets,
  Helge

PS: of course we should also update OGo to implement the new API, but thats quite a few places to fix.
--
Helge Hess
http://www.helgehess.eu/







reply via email to

[Prev in Thread] Current Thread [Next in Thread]