Note that there are some explanatory texts on larger screens.

plurals
  1. POapp crashes when clicks on alert in ios
    text
    copied!<p>Following are the code for displaying alert in a view controller</p> <pre><code>-(void)saveProducts { pData = [[JsonModel sharedJsonModel] prodData]; if ([pData count] == 0 &amp;&amp; [self respondsToSelector:@selector(alertView:clickedButtonAtIndex:) ] ) { alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"No products against this category" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } [self.tblView reloadData]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { [self.navigationController popViewControllerAnimated:YES]; [actInd stopAnimating]; } } </code></pre> <p>But in slow network, alert will come slowly. If we click on back button of navigation bar at the mean time, pop the navigation controller and displaying alert in new view controller. But when i clicks on OK, app suddenly crashes with EXC_BAD_ACCESS error. I also tried </p> <blockquote> <p>didDismissWithButtonIndex</p> </blockquote> <p>function instead of </p> <blockquote> <p>clickedButtonAtIndex</p> </blockquote> <p>But same error occurs. Please help me </p> <p>It works normally if we didn't click on back bar button. Problem only arises when first view controllers alert displays in second view controller</p> <p><strong>EDIT</strong> This is the error report <em>*</em> -[ProductsListing alertView:didDismissWithButtonIndex:]: message sent to deallocated instance 0x8478280</p> <p><strong>EDIT</strong> I understand the problem. When I click on back button, my alert delegate deallocates and delegate calling results error. How can I overcome this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload