Re: Connecting a custom control to manipulate NSArrayController's selection.
Re: Connecting a custom control to manipulate NSArrayController's selection.
- Subject: Re: Connecting a custom control to manipulate NSArrayController's selection.
- From: mmalc crawford <email@hidden>
- Date: Sun, 25 Mar 2007 19:02:20 -0700
On Mar 25, 2007, at 5:57 PM, Scott Andrew wrote:
I am using MUPhotoView for displaying a list of pictures. However i
have a bunch of my controls that update based on the selection of
the photo by connecting to the NSArrayContoller's "selection" key.
The selection is a proxy object:
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSObjectController_Class/Reference/Reference.html
>.
I have done the following:
[photoView bind:@"selectedPhoto"
toObject:imagesToExportController withKeyPath:@"selection"
options:nil];
i have then added the following:
-(NSObject*)selectedPhoto
{
return selectedPhoto;
}
-(void)setSelectedPhoto:(NSObject*)obj
{
[self willChangeValueForKey:@"selectedPhoto"];
selectedPhoto = [obj retain];
[self didChangeValueForKey:@"selectedPhoto"];
}
Nowhere in the documentation will you find an accessor method
illustrated like this.
For examples of correct ways to implement accessor methods, see
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAccessorMethods.html
>
If you need to make an accessor method KVO-compliant, you may include
the KVO notification method invocations, however typically this is not
necessary:
<http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/AutoVsManual.html
>
Moreover:
As my selection changes i call setSelectedPhoto. However i don't get
any updates in my other controls as my selection changes. How do i
update my array controller as my selection changes in the control
and have it post changes to the other controls
By sending it a suitable message (e.g. setSelectionIndexes:).
Please review <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/WhatAreBindings.html
>.
Information is communicated model >> controller >> view using KVO, but
view > controller > model using KVC. Posting KVO notifications from a
view is generally not useful (WebView is an anomaly since it combines
the roles of controller and view).
For several examples, see <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
>; note in particular the GraphicsBindings example...
mmalc
_______________________________________________
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