开发者

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

开发者 https://www.devze.com 2023-02-16 23:59 出处:网络
What is the full sequence events in terms of how a view controller loaded into memory from init to viewDidLoad?

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消