Re: What exactly does NSController do?
Re: What exactly does NSController do?
- Subject: Re: What exactly does NSController do?
- From: Chase Meadors <email@hidden>
- Date: Fri, 20 Nov 2009 16:02:51 -0600
Thought I'd give the question another try. Any insight appreciated.
On Nov 18, 2009, at 7:44 PM, Chase Meadors wrote:
I wanted to add that my problem in the second part of my question
has been solved. The only reason it wasn't working was that
graphView is actually a CALayer, and doesn't automatically call -
willChange and -didChange. Doing that solves the issue.
However, my question becomes more strange, as now I have many
working bindings systems in my code without any NSControllers.
Binding to plain old NSObjects seems to be fine. What is the purpose
of NSController?
On Nov 18, 2009, at 7:11 PM, Chase Meadors wrote:
Maybe I'm missing some things here, but hey; that's what I come to
the list for.
I'm not fully understanding the need for NSController's and/or what
they do.
Say I have an NSObject subclass:
---- (.h)
@interface TestObject : NSObject {
BOOL boolProp;
}
@property BOOL boolProp;
---- (.m)
@synthesize boolProp;
----
If I have an arbitrary checkbox, which I bind to MyObject.boolProp,
the connection works. I observe the property changing if the
checkbox is changed, and if, within code, I call self.boolProp =
YES, the check box changes.
However, once in a while, I'll have random problems that are fixed
with the addition of a mediating NSObjectController. For example, I
have a class WindowTwoController, which declares property IBOutlet
id graphView, which has the property BOOL isActive. I have a
checkbox in the window for one of these controllers bound to
myWindowTwoController.graphView.isActive
If, in the code for WindowTwoController, I call
self.graphView.isActive = NO, the checkbox does not change.
However, if I add an NSObjectController with content set to
myWindowTwoController, and bind the checkbox through that with the
selection key, then in my code for WindowTwoController:
[[self myObjectController] setValue:[NSNumber numberWithBool:NO]
forKeyPath:@"selection.graphView.isActive"];
then the check box is responsive.
What exactly is the magic that NSController performs? How come
simple bindings work without it?
Thanks for any replies!
_______________________________________________
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