binding to struct
binding to struct
- Subject: binding to struct
- From: "ad veloper" <email@hidden>
- Date: Tue, 11 Sep 2007 20:56:21 +0100
My View class has a number of structs which I'd like to bind to. I garbled
mmalc's example which is discussed here:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/HowDoBindingsWork.html,
and managed to get things running with one of my struct.properties. However,
I am a little perturbed by the amount of code I'm having to write in order
to establish bindings with the number of attributes that I have. Is this
just par for the course, or am I missing something?
As it stands it is much simpler to use an arraycontroller to manage the
Model and get the current selection from it and manipulate the
valueForKeyPath's in the model directly and eliminate the structs
altogether, but then this seems to shunt the model too far up into the view
violating MVC, as well as making changes to values tedious in the extreme
with endless reams of:
float x = [[modelObject valueForKeyPath:@"vector.x"] floatValue];
x+=1;
[[modelObject setValue:[NSNumber numberWithFloat:x] forKeyPath:@"vector.x"];
type code, rather than a rather more straightforward as per mmalc's
examples:
vector.x+=1;
Lesser of two evils or am I doing something wrong?
_______________________________________________
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