Hi folks
I just wanted to confirm a possible bug in the NSKeyValueObserving class.
Using Reflector to check the initialisation of this class, I see the
following :
static NSKeyValueObserving()
{
NSKeyValueChangeKindKey =
NSString.NSPinnedString("NSKeyValueChangeKindKey");
NSKeyValueChangeNewKey =
NSString.NSPinnedString("NSKeyValueChangeNewKey");
NSKeyValueChangeOldKey =
NSString.NSPinnedString("NSKeyValueChangeOldKey");
NSKeyValueChangeIndexesKey =
NSString.NSPinnedString("NSKeyValueChangeIndexesKey");
}
Unfortunately, in a test OS X app that implements KVO, I have the
following method to respond as observer to a property change :
void observeValueForKeyPathOfObjectChangeContext(NSString keyPath,
NSObject obj, NSDictionary change, Object context)
{
NSString keyStr = NSKeyValueObserving.NSKeyValueChangeNewKey;
Id valueId = change[keyStr];
...
}
This doesn't work, as the key, which equates to
"NSKeyValueChangeNewKey", is not found in the change NSDictionary.
However, If I do this :
void observeValueForKeyPathOfObjectChangeContext(NSString keyPath,
NSObject obj, NSDictionary change, Object context)
{
NSString keyStr = "new";
Id valueId = change[keyStr];
...
}
I get the expected result of the value for the "new" key.
Is this meant to be like this? If so, how would I get things to work? If
not, how do I get this submitted to the bug system?
Joanna
--
Joanna Carter
Carter Consulting