UIViewController -dealloc method not called

后端 未结 4 1420
半阙折子戏
半阙折子戏 2021-01-03 02:43

I am working with Automatic Reference Counting. I have a custom UIViewController subclass and whenever I call -presentViewController: animated:completion

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 03:30

    To get a print when the View Controller is deallocated you can implement the dealloc method as

    - (void) dealloc {
        NSLog(@"The instance of MyViewController was deallocated");
    }
    

    Then to get a print when the View Controller left the view you can implement

    - (void) viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
        NSLog(@"The instance of MyViewController left the main view")
    }
    

提交回复
热议问题