shannoga
shannoga

Reputation: 19869

Crash when UIAlertView dismissed

  1. I am using ARC.
  2. I show an alert view after a user taps a UITableView cell.
  3. 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

Upvotes: 1

Views: 817

Answers (1)

pdriegen
pdriegen

Reputation: 2039

You're setting the delegate of the UIAlertview to the calling UIViewController. That UIViewController is 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 the UIAlertView will be dismissed.

Upvotes: 3

Related Questions