Sorting an editable tableView of managed object
Sorting an editable tableView of managed object
- Subject: Sorting an editable tableView of managed object
- From: Steve Cronin <email@hidden>
- Date: Fri, 03 Jul 2009 17:00:59 -0500
Folks;
I have a simple one column tableView of a managed object.
The text field in the table view is editable.
I want to keep the table sorted when the user manually changes a value,
I have registered for the notification:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myRefreshManagedObjects:)
name:NSManagedObjectContextObjectsDidChangeNotification object:[self
managedObjectContext]];
This notification is called at appropriate times.
I iterate over the updated set NSUpdatedObjectsKey checking for the
entity.
If I find a match I determine what tableView is to be updated and call
a method which does the following;
- (void) sortManagedTable:(NSTableView *)tableView; {
//array controllers use 'prepare content' and a fetch predicate
//there is NO binding to a sortDesctiptor - the tableView handles the
header clicks correctly without one
NSSortDescriptor *titleDescriptor = [[tableView
tableColumnWithIdentifier:@"titleValue"] sortDescriptorPrototype];
NSMutableArray *newSortDescriptors = [NSMutableArray arrayWithArray:
[tableView sortDescriptors]];
[newSortDescriptors removeObject:titleDescriptor];
[newSortDescriptors insertObject:titleDescriptor atIndex:0];
[tableView setSortDescriptors:newSortDescriptors];
[tableView scrollRowToVisible:[[tableView selectedRowIndexes]
firstIndex]];
[tableView setNeedsDisplay];
}
But the tableView does not update to reflect the new ordering.
What am I missing?
Steve
_______________________________________________
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