Reputation: 31
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior
This warning appear just once. I alloc the UIAlertView
in a base:
viewController's viewDidLoad`self.alertView = [[UIAlertView alloc] initWithTitle.....`,
and
`- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
self.alertView = nil;
}`
viewController A and viewController B inherit from the base viewController.
When this viewController A push to a viewController B the warning appear but B pop to A and A push to B again ,this warning doesn't appear.
When I use the simulator (iOS 9.2), the warning appears, but when I use an iPhone (iOS 8.2), it doesn't appear.
Upvotes: 1
Views: 2204
Reputation: 31
Don't alloc init the alertView in viewDidLoad, alloc the alertView when you use it;
Upvotes: 2
Reputation: 102
if i right understand You define alert in Base class and need to show it only in A:Base but not in B:Base. if so here is code:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:(BOOL)animated];
if ([self isKindOfClass[A class]]) {
[self presentViewController:self.alert animated:YES completion:nil];
}
}
Upvotes: 0
Reputation: 6369
It's no need to dealloc properties in ARC.If you have some particular needs,please do this in viewWillDisappear
.
Upvotes: 0