• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Sorting an editable tableView of managed object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: in search of a starter iphone painting tutorial or sample code
  • Next by Date: Re: in search of a starter iphone painting tutorial or sample code
  • Previous by thread: Negative values in KVC's @sum?
  • Next by thread: Re: Sorting an editable tableView of managed object
  • Index(es):
    • Date
    • Thread