binding to struct

  • 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/Con
    cepts/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?
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today