Jonas Anderson
Jonas Anderson

Reputation: 1987

Can viewDidLoad get called before 'init' of a viewController is fully executed?

What is the full sequence events in terms of how a view controller loaded into memory from init to viewDidLoad?

If you do something like:

TabControllerClass *cc = [[TabControllerClass alloc] initWithCustomData:something];

Can the class's viewDidLoad get invoked before reaching the end of the custom init method, 'initWithCustomData'?

- (id)initWithCustomData:(NSString *)something
{
    if (self = [super init])
    {
        // A bunch of other initialization happens
    }

    // Would you reach here before 'viewDidLoad' is invoked?
    return self;
}

where my TabControllerClass inherits from UITabBarController.

Upvotes: 5

Views: 1534

Answers (1)

Alexsander Akers
Alexsander Akers

Reputation: 16024

I assume not. I mean, how can any method be called before the controller is correctly allocated and initialized? However, you may find that your -[ControllerClass initWithCustomData] initializer isn't the designated initializer, which could explain why it isn't being called.

Upvotes: 3

Related Questions