In what order are the following methods called for a UITableView?
numberOfSectionsInTableView
numberOfRowsInSection
cellForRowAtIndexPath
heightForRowAtIndexPath
didChangeObject
(NSFetchedResultsController
)Please include any other pertinent hook methods that I may have left out.
I would be wary about being concerned with the order in which these methods are called. These methods have very specific, and complete purposes. Even though the methods are called in a certain order right now, that doesn't mean they will always be called in that order so it is dangerous to make assumptions in your code as to what order they are called. For example, cellForRowAtIndexPath is not called for all rows. It is only called for visible rows and then called for additional rows as the user scrolls to them. Old rows are also destroyed as they go off the screen and it will request the cells again if the user scrolls back up.
Bottom line, since the order is not specified in Apple's documentation, you cannot safely assume that they will always be called in the same order and it is generally not a good idea to make such assumptions in your implementation.
I eventually did use NSLog
statements to figure this out but unfortunately didn't document it. For, I realized that the order those functions are called didn't matter.
Reading about Batch Insertion, Deletion, and Reloading of Rows and Sections in the Table View Programming Guide for iOS I learned to update the data before inserting rows in the table view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With