Re: KVC error from bound SortDescriptor
Re: KVC error from bound SortDescriptor
- Subject: Re: KVC error from bound SortDescriptor
- From: Keary Suska <email@hidden>
- Date: Wed, 14 Jan 2009 09:35:17 -0700
On Jan 14, 2009, at 4:54 AM, Steven Hamilton wrote:
I have a customer WindowController class and within it I have a
method that returns a NSSortDescriptor. Like this;
-(NSArray *)nameSortDescriptors
{
NSSortDescriptor *sorter;
sorter = [[[NSSortDescriptor alloc]
initWithKey: @"name"
ascending: YES] autorelease];
return ([NSArray arrayWithObject: sorter]);
}
In my NIB I have an NSArrayController serving a Core Data entity
called "Account". I've bound this entity to the SortDescriptor above
and the data is displayed in a bound NSTableview.
I'm getting the following error whenever I click the column header
to re-order the tableView and I can't understand why the array
controller is trying to set the sortdescriptor method or what to do
to surpress it.
Error setting value for key path nameSortDescriptors of object
<MLAccountController: 0x58ae390> (from bound object
<NSArrayController: 0x589d1a0>[entity: Account, number of selected
objects: 1](null)): [<MLAccountController 0x58ae390>
setValue:forUndefinedKey:]: this class is not key value coding-
compliant for the key nameSortDescriptors.
The sortDescriptors binding is just like any other binding. Just like
when binding to a text field, when you edit the text field, the
binding causes your model's bound value to change as well. So, when
you try to reorder the tableview, you are altering the sort
descriptors, so the binding tries to change your model's bound
property. You have two choice: 1) don't allow the table to be re-
sorted; or 2) make nameSortDescriptors key value coding compliant.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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