Arnlee Vizcayno
Arnlee Vizcayno

Reputation: 2426

UIAlertView crash in iOS 6

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.

Upvotes: 5

Views: 2507

Answers (1)

Arnlee Vizcayno
Arnlee Vizcayno

Reputation: 2426

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

Upvotes: 10

Related Questions