title: selecting and editing a new object in NSTableView
body: <p>I'm trying to select and edit the name property of a newly added object.</p>
  
  <p>On OSX, I have an array controller which displays its content in a table view. I have the table column's values connected (using bindings) through the AC's properties. Also, I set the table view's content and selectionIndexes bindings to point to the AC.</p>
  
  <p>My subclassed AC has an IBOutlet to the table view (called tableView), and contains managed objects from a data model.</p>
  
  <p>In my AC, I override the add: method. </p>
  
  <pre><code>- (void)add:(id)sender {
      [super add:sender];
      [[self managedObjectContext] processPendingChanges]; // no effect
      [tableView reloadData]; // no effect
      [tableView scrollRowToVisible:[[self arrangedObjects] count]-1];
  }
  </code></pre>
  
  <p>The newly added object appears in the table view in a selected state (I have the AC set up in IB to select newly inserted objects). But the table view scrolls down to the second last row, putting the new row just outside the visible view.</p>
  
  <p>When I try this,</p>
  
  <pre><code>[tableView scrollRowToVisible:[tableView selectedRow]];
  </code></pre>
  
  <p>or this,</p>
  
  <pre><code>[tableView scrollRowToVisible:[self selectionIndex]];
  </code></pre>
  
  <p>it gets even worse: the selectionIndex does not seem to be updated correctly.</p>
  
  <pre><code>- (void)add:(id)sender {
      [super add:sender];
      NSLog(@"selectionIndex = %lu", [self selectionIndex]);
      NSLog(@"number of objects in AC = %lu", [[self arrangedObjects] count]);
  }
  </code></pre>
  
  <p>Logging the selectionIndex reveals that it always shows the previous selection index.
  Logging the number of objects in the AC is always one too little.</p>
  
  <p>Am I trying to manipulate the table view too early? Any ideas which method would be better suited to override?</p>
  
  <hr>
  
  <p>About the editing part..</p>
  
  <p>The following statement interferes with the above scrollRowToVisible: method, as the last argument seems to select the row as well.</p>
  
  <pre><code>[tableView editColumn:0 row:0 withEvent:nil select:YES];
  </code></pre>
  
  <p>Anyway, the specified field (for testing purposes the first row of the table) seems to go into editing mode for just a flicker of an instant, but then finishes editing immediately.</p>
  
  <p>Any help would be greatly appreciated.</p>