Getting Exc_Bad_Access in UIAlertView show message.
UIAlertView *systemAlert1 = [[UIAlertView alloc]initWithTitle:@"System message" message:@"note" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[systemAlert1 show]; **//Crashing on this line [EXC_BAD_ACCESS]**
[systemAlert1 release];
Why i am getting this?? Please help
ANY UI stuff including the showing of alerts should be done on Main thread.
If you are doing this on some other thread, it will definitely crash.
It may be because your alert gets invoked from your background thread and not the main thread. It is recommended that user interface related changes should only be made on Main Thread to avoid this kind of behaviors of the application
Try this code:
UIAlertView *systemAlert1 = [[UIAlertView alloc]initWithTitle:@"System message" message:@"note" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[systemAlert1 performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
[systemAlert1 release];
Hope this helps. Let me know if you need anything else.