Re: Need help setting up KVO
Re: Need help setting up KVO
- Subject: Re: Need help setting up KVO
- From: Yevgeniy Goldberg <email@hidden>
- Date: Thu, 22 Mar 2007 09:16:23 -0500
Thanks, Måns!
Worked just like you said.
Best regards,
-Eugene
On Mar 22, 2007, at 8:56 AM, Måns Severin wrote:
Make an outlet (in my example called oArrayController) of your
controller class in the nib file where your arraycontroller is
residing and control drag from your controller class to the
arraycontroller to establish a connection.
In your controller class, add the methods:
- (void)awakeFromNib
{
[oArrayController addObserver:self forKeyPath:@"selection"
options:NSKeyValueObservingOptionNew context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context
{
if ( object == oArrayController && [keyPath isEqual:@"selection"] )
{
NSArray *selectedObjects = [oArrayController selectedObjects];
// Do something with selectedObjects here
}
}
Should work fine!
/måns
On 22 mar 2007, at 14.31, Yevgeniy Goldberg wrote:
Sounds like a straight-forward idea.
I can only see an instance of my arraycontroller (named "Sound
Array Controller") in my Nib file
How can I establish a reference to it from my code?
-Eugene
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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)
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