Table View will not refresh... (TahDoodle)


#1

Really hoping someone can help me out here. My app launches and appears to be running fine. However whenever I hit the insert button nothing happens. If I quit the app and relaunch the new items are created and I can edit them. It’s frustrating. I’m only just beginning so don’t know how to debug this yet.

From what I gather all of this should happen in the createNewItem method. I have double checked that I’ve typed everything in okay but still no luck. Here is the code for this particular method. Would really appreciate any help to debug this.

- (IBAction)createNewItem:(id)sender
{
    // If there's not array yet, go ahead and create one to store our new task
    if (!todoItems) {
        todoItems = [NSMutableArray array];
    }
    
    [todoItems addObject:@"New Item"];

    // -reloadData tells the table view to refresh and ask its dataSource
    // (which happens to be this BNRDocument object in this case) for new data to display

    [itemTableView reloadData];

    // -updateChangCount: tells the application whether or not the document
    // has unsaved changes. NSChangeDone flags the document as unsaved
    [self updateChangeCount:NSChangeDone];

}

#2

Ok - Finally found this. Documenting in case others run into the same problem.

Whilst my code was perfect, it appears that the itemTableView outlet was not connected to File’s Owner. The connection was there the other way FO -> iTV but not iTV -> FO.

Maybe a trap for young players. Happy that I finally worked it out myself. Unhappy that it took 3 hours! :angry: :unamused:


#3

[quote=“Jordan”]Ok - Finally found this. Documenting in case others run into the same problem.

Whilst my code was perfect, it appears that the itemTableView outlet was not connected to File’s Owner. The connection was there the other way FO -> iTV but not iTV -> FO.

Maybe a trap for young players. Happy that I finally worked it out myself. Unhappy that it took 3 hours! :angry: :unamused:[/quote]

Thanks for documenting this. Somehow I missed the connection as well but when back and re-read page 200 and found I didn’t connect FileOwner -> NSTableView.

-Ron