Cannot get NSTableView to reload!

Discussion in 'Mac Programming' started by DavidLeblond, Sep 24, 2004.

  1. macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
    #1
    I have a tableview that is bound to an array controller. I can add records just fine by using the array controller's add: action. However there is one part in the code that I wish to add additional records. I can add the records to the array controller just fine, but the NSTableView will not add. After I add the records, I can run the "add:" action and the tableview will reload and only then I can see the added records.

    Here is a snippet of my code:

    Code:
          Author *newAuth;
    	newAuth = [[Author alloc] init];
    	[[newAuth properties] setValue:@"first" forKey:@"firstname"];
    	[[newAuth properties] setValue:@"lost" forKey:@"lastname"];
    	[_authors addObject:newAuth];
    
    	[newAuth release];
    	[authorsView reloadData];
    
    authorsView is an Outlet connected to my table that is bound to the array controller (_authors, which is an array of Author)

    Any ideas? I have tried everything to try to get that thing to refresh!
     
  2. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #2
    Are you saying that the [authorsView reloadData] isn't doing anything?
     
  3. thread starter macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
    #3
    Exactly... just breezes right by it. No errors, no warnings, no nothing.
     
  4. thread starter macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
    #4
    I also noticed this about my Interface, where I connected the TableViews to the controller:

    [​IMG]

    Notice the indexes of the NSTableViews are (,) and ()... why is that? Could that be causing this? :confused:
     
  5. macrumors 68000

    Fukui

    Joined:
    Jul 19, 2002
    #5
    Try removing [newAuth release]; and see what happens...
     
  6. thread starter macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
    #6
    Doesn't work.

    I should also add, that after adding the newAuth object to the tableView I can get it to appear by changing the sort order on the view by clicking the column headers.
     
  7. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #7
    Oh, I just thought of something. What happens if you send a setNeedsDisplay message right after the reload? I'm thinking that it doesn't visually update without a little kick so that a series of adds won't be too slow.

    [I'll also note that others have encountered this problem if an NSTableView's controller happens to be subclassed from NSDocument.]
     
  8. thread starter macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
    #8
    That didn't work. Good guess though!

    There's gotta be something I'm not doing right, I just wish I could figure out what! :mad:
     
  9. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #9
    'Fraid of that. tableviews are definitely buggy. Lots of stuff here on random problems epople have with them and a few workarounds. Good luck (and do tell us what eventually works!)
     
  10. thread starter macrumors 68020

    DavidLeblond

    Joined:
    Jan 6, 2004
    Location:
    Raleigh, NC
  11. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #11
    Grrrrr. Since Openstep is already a published spec, would it really kill them to show the source code for Cocoa? The documentation they supply really doesn't cut it.
     

Share This Page