Possibly the crash is due to dismissing and showing the UIAlertView
from other thread.
Never do UI
tasks in other threads. UI
tasks should be done in Main Thread.
Change function
like:
-(void)function
{
// Do some web request
dispatch_async(dispatch_get_main_queue(), ^{
[alertView dismissWithClickedButtonIndex:0 animated:NO];
if(response == nil)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Timeout", @"") message:NSLocalizedString(@"Connection timeout", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"Close", @"") otherButtonTitles:nil ];
[alert show];
}
});
}