Re: Binding/KVC : valueForKey: and NSDictionary (was: valid accessor for framework objects. (was: implicit and explicit invocation of description method))
Re: Binding/KVC : valueForKey: and NSDictionary (was: valid accessor for framework objects. (was: implicit and explicit invocation of description method))
- Subject: Re: Binding/KVC : valueForKey: and NSDictionary (was: valid accessor for framework objects. (was: implicit and explicit invocation of description method))
- From: Max Barel <email@hidden>
- Date: Tue, 5 Oct 2004 23:29:40 +0200
Le 5 oct. 04, à 15:54, Max Barel a écrit :
In a more general description:
- The NSArraycontroller manage an array of NSScreen (tried both
NSArray and mutable copy).
- Its object class is defined as NSScreen.
- NSScreen objects have a property named deviceDescription, of class
NSDictionary.
No accessor of the form selection.deviceDescription.amethod[an
NSArraycontroller] works.
Accessors of the form selection.deviceDescription.aKey (e.g
selection.deviceDescription.NSDeviceSize) work once. Changing the
initial selection crash on signal 10.
Can we suspect a weird behavior with NSDictionary to-one relationship?
After more testing and cross-reading of the valueForKey: method
documentation, I come with a differently formulated question:
The valueForKey: method is defined in the NSKeyValueCoding protocol of
NSObject. It is also overloaded in NSDictionary.
Is the NSDictionary version of the method conforming to the
NSKeyValueCoding?
I understand that the overloaded version add the ability to find a
value from a key (in the NSDictionary sense), but it is still able to
find a public method, as stated by the first rule of KVC:
valueForKey:
- (id)valueForKey:(NSString *)key
...
The default implementation works as follows:
1. Searches for a public accessor method based on key. For example,
with a key of “lastName”, valueForKey: looks for a method named
getLastName or lastName
...
For example, none of the test I made allowed me to access the value
from the -count method of an NSDictionary object using KVC.
Max
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden