viewDidLoad in NSViewController?

前端 未结 6 521
走了就别回头了
走了就别回头了 2020-12-01 02:15

On the iPhone I use UIViewController\'s viewDidLoad to run code to set up the view.

How can I do that with NSViewController?

6条回答
  •  情书的邮戳
    2020-12-01 02:28

    hmm actually I would also do this...

    - (void)viewWillLoad {
    
        if (! bool_viewwillload) {
    
            // execute the code
            bool_viewwillload = true;
        }
    }
    
    - (void)viewDidLoad {
        if (! bool_viewdidload) {
    
            // execute the code
            bool_viewdidload = true;
        }
    }
    

    and then just make the load view like this

    - (void)loadView {
    
        [self viewWillLoad];
    
        [super loadView];
    
        [self viewDidLoad];
    }
    

提交回复
热议问题