title: NSOutlineView won't reload data on keydown, but updates on focus
body: <p>I've been trying to figure this issue out for the last couple of hours with a lot of searching involved and watching videos.  Here's what I'm trying to do:</p>
  
  <p><strong>Summary</strong>: A simple window allowing me to move a message from my inbox to any of my many mail folders. As I type the name of the mail folder I'm looking for, the outline view should automatically refresh only displaying the ones with the matching text - think MsgFiler if you know it.</p>
  
  <ul>
  <li>Type text in text box </li>
  <li>As I type each letter, I want the NSOutlineView to update it's data to have less and less folders that match my input text. (At the moment, my test just adds a "Test Mailbox" into the NSOutlineView</li>
  </ul>
  
  <p><strong>Current result</strong>:</p>
  
  <ul>
  <li>Type text in text box</li>
  <li>Nothing happens</li>
  <li>Click the NSOutlineView, the view gets updated</li>
  </ul>
  
  <h1>TextfieldDelegate.m:</h1>
  
  <pre><code>#import "TextFieldDelegate.h"
  #import "OutlineViewController.h"
  #import "GetMailDatasource.h"
  
  @implementation TextFieldDelegate
  
  @synthesize testLabel;
  
  - (void) controlTextDidChange :(NSNotification *) sender {
    NSTextField *changedField = [sender object];
    NSLog(@"in control text did change");
  
    //Just some text code to see the change when text does change
    NSString *text = [changedField stringValue];
    [testLabel setStringValue:text];
  
    NSLog(@"changed the label and creating the data now");
  
    OutlineViewController *vc = [[OutlineViewController alloc] init];
    [vc refreshTheData:sender];
    [vc.outlineView reloadData];
    [vc release];
  }
  
  - (void)controlTextDidEndEditing:(NSNotification *)obj {
    NSLog(@"in end editting");
    return;
  }
  
  @end
  </code></pre>
  
  <h1>OutlineViewController.m</h1>
  
  <pre><code>#import "OutlineViewController.h"
  #import "GetMailDatasource.h"
  
  @implementation OutlineViewController
  
  - (id) init {
  
    self = [super init];
    if (self) {
      _mailboxes = [[NSMutableArray alloc] init];
      if (myMailboxes != nil) {
          _mailboxes = myMailboxes;
      } else {
          GetMailDatasource *mailDatasource = [[GetMailDatasource alloc] init];
          [mailDatasource createFakeData];
          _mailboxes = myMailboxes;
      }
    }
  
    NSLog(@"inited outline view controller");
    return self;
  }
  
  - (IBAction) refreshTheData : (id) sender {
  
    NSLog(@"in refreshTheData");
  
    Mailbox *m = [self.outlineView itemAtRow:[self.outlineView selectedRow]];
    if (m)
       [m addChild:[[Mailbox alloc] init]];
    else
        [self.mailboxes addObject:[[Mailbox alloc] init]];
  
    NSLog(@"running reloadData");
    [self.outlineView reloadData];
  }
  
  #I know these work, but providing them for completeness
  #pragma mark NSOutlineView Data Source Methods
  
  - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
      return !item ? [self.mailboxes count] : [[ item children] count ];
  }
  
  - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
      return !item ? YES : [[item children ] count] != 0;
  }
  
  - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
      return !item ? [self.mailboxes objectAtIndex:index] : [[item children] objectAtIndex:index];
  }
  
  - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
      return [item name];
  }
  
  @end
  </code></pre>
  
  <p>I do have a separate "Test Button" that I added on the interface just to try out and I've bound it's "Sent action" directly to the "refreshTheData" function on the OutlineViewController and that works without a hitch.  Adds the new item in the NSOutlineView and it updates immediately.</p>
  
  <p>I'm not sure what else is required to try to figure out where the problem lies... Any suggestions would be much appreciated!</p>
  
  <p>Many thanks!</p>