why are there 2 update change count in the code of TahDoodle.
One in addTasks method and one in the method of protocol. Here is the code
[code]-(void)addTasks:(id)sender{
//If there is no array yet, create one
if (!self.tasks){
self.tasks = [NSMutableArray array];
}
[self.tasks 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
[self.taskTable reloadData];
//-updateChangeCount : tells the application whether or not the document
//has unsaved changes, NSChangeDone flags the document as unsaved
[self updateChangeCount:NSChangeDone];
}
[/code]
and protocol’s method code
[code]-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
//when the user changes a task on the table view, update the tasks array
[self.tasks replaceObjectAtIndex:row withObject:object];
//And then flag the document as having unsaved changes.
[self updateChangeCount:NSChangeDone];
}[/code]