Reputation: 67
Result:
2014-05-12 11:17:24.891 viewController[2206:60b] init
2014-05-12 11:17:24.910 viewController[2206:60b] loadView
2014-05-12 11:17:24.911 viewController[2206:60b] viewDidLoad!
2014-05-12 11:17:24.912 viewController[2206:60b] viewWillAppear
2014-05-12 11:17:24.916 viewController[2206:60b] dealloc
2014-05-12 11:17:24.982 viewController[2206:60b] viewDidAppear
Why dealloc method between viewWillAppear method and viewDidAppear method?
- (id)init
{
if (self = [super init]) {
NSLog(@"init");
}
return self;
}
- (void)loadView
{
NSLog(@"loadView");
[super loadView];
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"viewDidLoad!");
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"viewWillAppear");
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"viewDidAppear");
}
- (void)dealloc
{
NSLog(@"dealloc");
[super dealloc];
}
Upvotes: 1
Views: 836
Reputation: 119292
From your comments:
The method dealloc log self address was changed! – user3349116
You're seeing logs from different instances of the view controller. Include self
in your logs when you're trying to trace activity like this. And make sure not to break the view controller while you're doing it (your loadView implementation will probably mean you have nothing to display on the screen).
In any case, the view controller life cycle is well documented and in most cases pretty obvious.
Upvotes: 1