ma11hew28
ma11hew28

Reputation: 126457

In what order are UITableView hook methods called?

In what order are the following methods called for a UITableView?

Please include any other pertinent hook methods that I may have left out.

Upvotes: 7

Views: 3515

Answers (2)

drewag
drewag

Reputation: 94733

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.

Upvotes: 12

ma11hew28
ma11hew28

Reputation: 126457

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.

Upvotes: 2

Related Questions