Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is viewDidLoad called?

Is it safe to assume that an attribute, namely fetchedResultsController, of chatViewController, an instance of a subclass of UITableViewController, is always nil when viewDidLoad is called, assuming that it's set to nil in viewDidUnload? Phew!

If that's the case, then I see no immediate need to redefine the accessor function like in the Xcode example application CoreDataBooks. I'd rather just put all that code in viewDidLoad instead of in a separate function because that's the only place I'll use it.

like image 518
ma11hew28 Avatar asked Oct 16 '10 17:10

ma11hew28


2 Answers

viewDidLoad is called after your view is loaded. Whether or not fetchedResultsController is nil or not depends on how the viewController is initialized. For example, when creating the detailViewController, you could set its fetchedViewController before viewDidLoad is called:

RecipeDetailViewController *detailViewController = [[RecipeDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
detailViewController.fetchedResultsController = fetchedResultsController;

[self.navigationController pushViewController:detailViewController animated:animated];
[detailViewController release];

That said, then nil'ing fetchedResultsController in viewDidUnload would ensure that it's nil.

like image 119
Jordan Avatar answered Sep 20 '22 02:09

Jordan


ViewDidLoad Called in These Secnarion:-

1.when we push the view controller after creating it’s object by segue or by stoary board id.

2.it called more than one in the case of creating instance more time in application and push it again and again.for example:-if you implement like coaursal(that having required to additional controller during scrolling) like that it’s need so it can called multiple times viewDidLoad.

3.it called when all memory instance (uiviewcontroller and it’s subclass instantiated) that means when our view is ready to load in memory with the address.

4.Remember only child class controller object is created..parent class object never been instantiated during normal Secnarion.

like image 41
Atal Singh Avatar answered Sep 22 '22 02:09

Atal Singh