Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
Im trying to determine in which order the various functions of a viewcontroller gets launched.

In particular, I would like to know which function gets launched BEFORE a tableview's (which is set up by the viewcontroller) cellForRowAtIndexPath-function.

If I can use any of my preexisting functions, that would be alright. They are:

- awakeFromNib
- viewWillAppear
- numbersOfSectionsInTableView
- tableview: numberOfRowsInSection
- viewDidAppear
- restoreLevel
 
It depends in part when your code calls reloadData. cellForRowAtIndexPath will be called shortly afterwards. awakeFromNib, loadView, viewDidLoad will be called before the table does anything. If you don't call reloadData in any of those methods I think that viewWillAppear and viewDidAppear will be called before your table starts to draw itself, but I'm not certain of that. numbersOfSectionsInTableView and numberOfRowsInSection will probably be called before cellForRowAtIndexPath but that starts to get murky because after the table starts calling its various callbacks the order becomes hard to predict.

Why do you want to know?
 
It depends in part when your code calls reloadData. cellForRowAtIndexPath will be called shortly afterwards. awakeFromNib, loadView, viewDidLoad will be called before the table does anything. If you don't call reloadData in any of those methods I think that viewWillAppear and viewDidAppear will be called before your table starts to draw itself, but I'm not certain of that. numbersOfSectionsInTableView and numberOfRowsInSection will probably be called before cellForRowAtIndexPath but that starts to get murky because after the table starts calling its various callbacks the order becomes hard to predict.

Why do you want to know?

Thanks, I found the reloadData-call in the viewWillAppear-function, and placing my initialization-code before that call made certain that it was in fact executed BEFORE the tableview was populated in the tableView's cellForRowAtIndexPath-function.

Ive got a drill-down hierachy of tableviews, and Im constructing a system where you can see wether youve visited a page already or not, and in higher hierarchies you should be able to see if youve visited all the pages in the subhierarchy of that cell. And so on. Pretty tedious coding, I must say. Wish there were a built in option in the tableview-class that could accomplish this task, but I havent found any.

Thanks again for your help :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.