I have a UIAlertView with the following delegate method:
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
But I have a problem. In that method, I do some logic and perform some lines of code which take a small amount of time. I would like to dismiss the alertView before I do all of this. I want to dismiss the alert view at the very top of that method. That way, when the user taps a button on the alertView, the app doesn’t seem frozen for a second while the next lines of code are executed.
Either use the delegate method
-alertView:didDismissWithButtonIndex:instead—it gets called once the alert view’s been removed from the screen, which will at least conceal the lag your app’s having—or, better, use a background thread, e.g. with-performSelectorInBackground:withObject:, to handle whatever processing you need to do.