Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertView crash in iOS 6

Tags:

ios

I have this code:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];

The problem is this code crash before it shows the alert, I have tested it on lower iOS and it work but on iOS 6 it crash.

like image 333
Arnlee Vizcayno Avatar asked Oct 18 '12 09:10

Arnlee Vizcayno


1 Answers

I found the answer. I coded:

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

instead of

[alert show];

it crash because the process might not be performed in the main thread.

Source from: https://stackoverflow.com/a/12475858/1179680

like image 98
Arnlee Vizcayno Avatar answered Oct 24 '22 04:10

Arnlee Vizcayno