Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXC_BAD_ACCESS code 2 on UIAlertView in iOS6

I'm trying to figure out why im getting this crash in my app.

It works perfectly fine in Xcode 4.4 running in the simulator with ios5.1, but when i switch into xcode 4.5 and ios6 I'm getting an EXC_BAD_ACCESS code 2. Here is my code:

- (void) myMethod {     UIAlertView *alertview = [[[UIAlertView alloc]initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];     alertview.tag = 1     [alertview show]; } 

this is giving me an EXC_BAD_ACCESS code 2 on the [UIAlertView show] line

any ideas?

thanks!

like image 238
Sean Danzeiser Avatar asked Sep 17 '12 23:09

Sean Danzeiser


1 Answers

I've got it. I have the same problem, in my case it seems that the method is thrown from background now (now in ios7, in ios6 UIAlertView was automatically put into the main-thread as @nodepond says -thanks!-)..

try to assure that the method is shown from main thread:

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

Good luck!

like image 134
Eva Madrazo Avatar answered Oct 04 '22 03:10

Eva Madrazo