UIAlertView Causes Crash in iOS SDK 6.0

kubilay picture kubilay · Sep 13, 2012 · Viewed 7.8k times · Source

I recently submitted an app to App Store that has not been accepted yet. Meanwhile, I downloaded Xcode 4.5 and tested my app in iPhone 6.0 Simulator.

However, when I intend to show an UIAlertView, the app crashes on [myAlertView show] line with EXC_BAD_ACCESS error. It works fine with iPhone 5.1 Simulator.

Here's my code:

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Are you sure?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[myAlertView show];  

Is that normal? What am I doing wrong with my code?

Also, do you think I should resend my app to Apple?(Just asking your advice)

Thanks in advance.

Edit: Apple has rejected the app because of iOS 6 crash.

Answer

Jordan picture Jordan · Jan 20, 2013

Delete this method and use the other method:

 [myAlertView show];  

Try this Method:

 [myAlertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];