I was trying to understand why numberOfSectionsInTableView is called several times every time I update my data source. From the stack trace in gdb, I see the following
#0 -[JobPickerTVC numberOfSectionsInTableView:] (self=0x4d61fe0, _cmd=0x6207f5, tableView=0x6034800) at JobPickerTVC.m:153
#1 0x003d66ff in -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] ()
#2 0x003d63b0 in -[UITableViewRowData invalidateAllSections] ()
#3 0x00299010 in -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] ()
#4 0x002891e8 in -[UITableView endUpdates] ()
#5 0x000050c8 in -[JobPickerTVC controllerDidChangeContent:] (self=0x4d61fe0, _cmd=0x17109d, controller=0x4da5e40) at JobPickerTVC.m:442
followed by
#0 -[JobPickerTVC numberOfSectionsInTableView:] (self=0x4d61fe0, _cmd=0x6207f5, tableView=0x6034800) at JobPickerTVC.m:153
#1 0x003d66ff in -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] ()
#2 0x003d6417 in -[UITableViewRowData ensureAllSectionsAreValid] ()
#3 0x0029902e in -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] ()
#4 0x002891e8 in -[UITableView endUpdates] ()
#5 0x000050c8 in -[JobPickerTVC controllerDidChangeContent:] (self=0x4d61fe0, _cmd=0x17109d, controller=0x4da5e40) at JobPickerTVC.m:442
From what I can tell, the code executes [UITableViewRowData invalidateAllSections ] (line # 2 of the first trace) and then [UITableViewRowData makeAllSectionsAreValid ] (line # 2 second trace). Both of them end by calling [JobPickerTVC numberOfSectionsInTableView:]. Thus, [JobPickerTVC numberOfSectionsInTableView:] is called twice. I would like to know why this happens and what these operations do.
Another call to numberOfSectionsInTableView for another reason, but I would like to figure this out first.