• 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: KVO: I get called on change, but then can't get the object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO: I get called on change, but then can't get the object


  • Subject: Re: KVO: I get called on change, but then can't get the object
  • From: Scott Anguish <email@hidden>
  • Date: Sat, 31 May 2008 20:00:32 -0400

array controllers are not fully KVO compliant.

they don't return change values.


On May 31, 2008, at 3:21 AM, Rick Mann wrote:

I registered to observe changes in the "number" column of my tree controller:

	[mItemsController addObserver: self
		forKeyPath: @"selection.number"
		options: (NSKeyValueObservingOptionNew)
		context: NULL];

My -observe: action gets called, but this line

NSLog(@"Value changed %@: %@ (%@)", inKeyPath, inChange, [inObject selection]);


dumps this to the console:

Value changed selection.number: {
   kind = 1;
   new = <null>;
} (<_NSControllerObjectProxy: 0x177cb0>)

Note that "new" is null. I would expect it to be the value of the number.

Furthermore, this line:

	NSLog(@"selection: %@", [inObject valueForKey: @"selection"]);

dumps:

	selection: <_NSControllerObjectProxy: 0x177cb0>

But if I change it to @"selection.number", it throws the exception:

"[<NSTreeController 0x1722e0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key selection.number."



From reading the docs:

"NSObjectController and its subclasses implement the selection method. This method returns a proxy object that represents the receiver’s current selection. The proxy is fully key-value-coding compliant.
When you request a key’s value from the selection proxy it returns the value, or a selection marker. Placeholder markers provide additional information about the selection. There are three placeholder markers defined in the NSPlaceholders informal protocol:"


It seems that I should be able to get the number from the selection, but instead I get the exception:

"[<NSTreeController 0x170c60> valueForUndefinedKey:]: this class is not key value coding-compliant for the key selection.number."



I feel like I should be able to get the number. Elsewhere I read that I would get an array of numbers. What am I doing wrong?



TIA,




-- Rick

_______________________________________________

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

_______________________________________________

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


References: 
 >KVO: I get called on change, but then can't get the object (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Copying NSTextStorage
  • Next by Date: Re: KVO: I get called on change, but then can't get the object
  • Previous by thread: Re: KVO: I get called on change, but then can't get the object
  • Next by thread: Defaulting new entity fields to be same as current selection?
  • Index(es):
    • Date
    • Thread