KVC error when asking for a sort (Core Data / Bindings)

  • Hello List,

    I have an NSTableView which is bound to an NSArrayController ; this controller represents "accountClass" Entities. On the NSArrayController, I have a sort descriptor bound to a function (called accountClassesSortDescriptors) that returns an array of NSsortDescriptors (actually, there is just one sort descriptor in this array right now; I initialized it with initWithKey: @"accountClass" ascending: @"YES").

    My data is sorted correctly when the table view is displayed, however as soon as I click a column header I get an error message in the log : "Error setting value for key path accountClassesSortDesciptors of object <blablaController> ... this class is not key value coding-compliant for the key accountClassesSortDescriptors".

    This definetely smells like a noob question to me, but I've been looking all over the place for 2 days now and I can't get this to work properly. Any thoughts on this ?

    Thanks,
    Alain
  • > have an NSTableView which is bound to an NSArrayController ; this
    > controller represents "accountClass" Entities. On the
    > NSArrayController, I have a sort descriptor bound to a function
    > (called accountClassesSortDescriptors) that returns an array of
    > NSsortDescriptors (actually, there is just one sort descriptor in
    > this array right now; I initialized it with initWithKey:
    > @"accountClass" ascending: @"YES").
    >
    > My data is sorted correctly when the table view is displayed,
    > however as soon as I click a column header I get an error message in
    > the log : "Error setting value for key path
    > accountClassesSortDesciptors of object <blablaController> ... this
    > class is not key value coding-compliant for the key
    > accountClassesSortDescriptors".

    Sounds like you need a matching "setAccountClassesSortDescriptors"
    method.  Not sure why code would be trying to set that value.  A
    breakpoint would be illuminating.  Perhaps something is bound in a way
    that the array controller expects the value to be read-write.

    - Ben
  • On Oct 31, 2007, at 8:39 AM, Alain Schartz wrote:

    > I have an NSTableView which is bound to an NSArrayController ; this
    > controller represents "accountClass" Entities. On the
    > NSArrayController, I have a sort descriptor bound to a function
    > (called accountClassesSortDescriptors) that returns an array of
    > NSsortDescriptors (actually, there is just one sort descriptor in
    > this array right now; I initialized it with initWithKey:
    > @"accountClass" ascending: @"YES").
    >
    > My data is sorted correctly when the table view is displayed,
    > however as soon as I click a column header I get an error message in
    > the log : "Error setting value for key path
    > accountClassesSortDesciptors of object <blablaController> ... this
    > class is not key value coding-compliant for the key
    > accountClassesSortDescriptors".
    >
    When you click the table column, the sort descriptors are updated.
    Since you've bound 'sortDescriptors', the array controller now
    attempts to update the value to which you've bound it...

    (Ben then shows the solution...)

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