• 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
What exactly does NSController do?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What exactly does NSController do?


  • Subject: What exactly does NSController do?
  • From: Chase Meadors <email@hidden>
  • Date: Wed, 18 Nov 2009 19:11:18 -0600

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


  • Follow-Ups:
    • Re: What exactly does NSController do?
      • From: Chase Meadors <email@hidden>
  • Prev by Date: Object with no roots not garbage collected
  • Next by Date: Re: firstResponder KVO snow leopard crash; bug?
  • Previous by thread: Object with no roots not garbage collected
  • Next by thread: Re: What exactly does NSController do?
  • Index(es):
    • Date
    • Thread