- I am using ARC.
- I show an alert view after a user taps a UITableView cell.
- 99% of the times everything works great.
NOW TO THE WEIRED PART
I have this view hierarchy –
UITableView –> First UIViewController –> Child UIViewControllerControllers
The crash only appears after I open one, specific child UIViewControllers. After I enter all the other child viewControllers the alert view works great. If I enter the “problematic” view controller even once, The UIAlert view will crash even 5 minutes later and even if I get into all the other view controllers.
I have to say again that the alertView is presented in the root UITableView. And that it crashes even if the alert view callback method is only NSLoging.
The crash report is:
*** -[ReviewViewController isKindOfClass:]: message sent to deallocated instance 0x20bea8d0
while ‘ReviewViewController’ is the problematic viewController.
Thanks
Shani
You’re setting the delegate of the
UIAlertviewto the callingUIViewController. ThatUIViewControlleris being de-allocated in certain cases when you navigate away from it.If you require a delegate to respond to the
UIAlertView, you’ll have to structure your code so that the delegate doesn’t get de-allocated before theUIAlertViewwill be dismissed.