bindings best practices

  • I have a button who's (when did buttons become who?) enabled binding
    is bound to selection.canAddNew of an NSTreeController. This works

    however if I do this:

    [self bind:@"testToAdd" toObject:treeController
    withKeyPath:@"selection.canAddNew" options:nil];

    I get gibberish back not canAddNew when I log the result in testToAdd
    (and I change the selection in my NSOutlineView). The documentation
    clearly states that selection returns a proxy object. Does that mean
    bindings set through interface builder are doing behind the scene
    magic like:

    [[[treeController selectedObjects] objectAtIndex: 0] canAddNew];

    Doesn't this mean that my bound method (accessor set) needs to have
    an understanding of NSObjectController classes and use the above
    selectedObjects code to get the value?

    It seems like I must be missing something when creating bindings

    Is there a better way to get the same behavior as IB through code? Or
    should I just observe selection or selectedObjects and then use the
    above code to get the actual object?

previous month october 2006 next month
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 31          
Go to today