On Aug 22, 2009, at 5:47 PM, Quincey Morris wrote:

On Aug 22, 2009, at 16:16, Michael de Haan wrote:

..........or a fundamental misunderstanding.

Fundamental misunderstanding. :)

That figures!



I have a checkbox, which I wish to bind to an iVar in my model ( which is a windowController).

No, you don't bind anything to an ivar, you bind things to properties.

My lack of correct syntax...but your point is well taken.




What I am doing right now is creating an NSButton object in the model, and "assuming" .....probably incorrectly, that by having the correct getters/setters available ( eg state/setState etc) I can bind the view's checkbox title, alternateTitle, status to the NSButton in the model. That is not working for me. ("Cannot create BOOL from object <NSButton: 0x19f6c0> of class NSButton").

Your NSButton object isn't *in* the model. It may be an outlet of the window controller,

Correct



but that's a feature of the controller role, not of the data model role, of the window controller. Bind *from* your view (the checkbox) *to* properties of your data model.

OK...that certainly clarifies one thing....so, one **cannot** bind to an object, but to that object's properties? (Hence the error when I tried that).



Specifically, in IB, you'll bind the NSButton's "value" binding to the "state" property of File's Owner (your window controller).

Is this my error, or do I need to create an iVar for each of the button elements I wish to bind to?

If you want to bind the "title" and "alternateTitle" bindings too (not that I'd recommend it -- the whole point of a checkbox is that the on/off state is shown by the checkmark, not by the text), then you must create properties of your window controller to bind to. These will be NSString* properties.

Perhaps I am not using the checkbox correctly, but I wish the label to illustrate that checked represents one type of unit ( eg pounds) and unchecked another ( eg kilograms).

( But, mainly I am trying to use my "Hillegass" knowledge as I work my way through his book. Just reading without trying to use it is pretty pointless to me and gives one a false sense of understanding...just IMHO. Plus making little apps that I use at work gives a sense of fulfillment.)



This issue, of ensuring correct propagation of your properties, is called "KVO-compliance", which you may have already come across.

Quincey, I **hope** my level of question did not imply that I was "KVO- ignorant" :-)

Thanks ...will try what you say.
Michael.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to