sortDiscriptor binding

  • Hi Guys,

    This is a binding question, here's the situation...

    ... MyDocument

    - (void)windowControllerDidLoadNib:(NSWindowController *)
    windowController
    ...
    NSSortDescriptor *orderDescriptor;
    orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"order"
    ascending:NO] autorelease];
    sortOrder = [[NSArray arrayWithObject:orderDescriptor] retain];
    ...

    in the NSArrayController Bindings sortDiscriptors

    bindings File's Owner (MyDocument)
    Model Key Path sortOrder

    This is tricky to explain. When I set the sortDiscriptor directly
    with setSortDiscriptor using an IBOutlet to the NSArrayController, it
    sets the sort order in the tableview. Just as required.
    But when I use bindings it doesn't seem to set it, but when you
    change the order by clicking on the column header it changes the
    sortOrder Array. So the binding is connected.

    The question seems to be...
    Why doesn't the sortDiscriptor get it's initial setting from the
    binding link to MyDocument when it gets setup?

    or am I going about this the wrong way...

    Cheers
    Kevin
  • On Oct 5, 2006, at 6:59 PM, Kevin Bracey wrote:

    > Why doesn't the sortDiscriptor get it's initial setting from the
    > binding link to MyDocument when it gets setup?
    >
    You're not setting the value in a KVO-compliant way...

    orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"order"
    ascending:NO] autorelease];
    sortOrder = [[NSArray arrayWithObject:orderDescriptor] retain];

    <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cepts/Troubleshooting.html
    >

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