Skip navigation.
 
mlCore Data: Forcing update of NSTableView bound to an NSArrayController
FROM : Bill Coleman
DATE : Wed Aug 09 04:35:48 2006

I previously had asked about performing a document-modal operation. I 
had tried using NSThreads, but due to the complex multi-threading 
issues, I've taken the advice of Jakob Olesen and am using what he 
termed a tail-call recursion using 
performSelector:withObject:afterDelay:.

This works quite well in creating a document-modal operation, my only 
complaint is that it pauses importing or exporting while you hold a 
menu down. I can live with that - kind of reminds me of old Classic 
MacOS applications that processed on Idle events.

When the import operation finishes, I do a number of calls to attempt 
to reposition the NSTableView to show the last item in the table. 
However, the NSTableView doesn't appear to recognize all the records 
I've imported until sometime after this, because the scroll position 
is still at the top. Or if a few records are recognized in the middle 
of the import, it scrolls to the end of the few it recognized.

Here's the code sequence after the import:

   [self endProgressSheet]; // puts away the document-modal sheet
       
   [arrayController rearrangeObjects];
   [tableView reloadData];
   [tableView scrollRowToVisible: [ [arrayController arrangedObjects] 
count] - 1];
   
I've noticed that if I include the [arrayController addObject:] call 
during my import, the NSTableView seems to keep up with the changes 
as I go, although it somehow messes up the putting away of the sheet 
at the end. Several responders indicated I shouldn't do that, since 
the array controller is bound to the managed context.

So, how to I force the table to update at the end?


Bill Coleman, AA4LR, PP-ASEL        Mail: <email_removed>
Quote: "Not within a thousand years will man ever fly!"
            -- Wilbur Wright, 1901



Bill Coleman, AA4LR, PP-ASEL        Mail: <email_removed>
Quote: "Boot, you transistorized tormentor! Boot!"
            -- Archibald Asparagus, VeggieTales

Related mailsAuthorDate
mlCore Data: Forcing update of NSTableView bound to an NSArrayController Bill Coleman Aug 9, 04:35
mlRe: Core Data: Forcing update of NSTableView bound to an NSArrayController John Bishop Aug 9, 15:12
mlRe: Core Data: Forcing update of NSTableView bound to an NSArrayController Bill Coleman Aug 10, 02:24
mlRe: Core Data: Forcing update of NSTableView bound to an NSArrayController Bill Coleman Aug 10, 05:16