I have a method that gets launched by a UIBarbuttonitem click. In that the first step is launch a alert view. Then a background thread starts to pull data from web service. I made sure that alert view is shown on main thread by using performselectoronmainthread. But still there is a 13 second delay from when i click the barbutton click and showing of alert view. Here is the code.
Why is alert view not showing up immediately. OR Why is my UIThread( i am assuming my main thread) not showing the alertview immediately. Any help would be great. I am trying to get to solve this past 5 hours. So please help. It is in iOS 6.0 and iPad in-house project. If you need more information, please ask. Thanks.
Code:
- (void)refreshDataAction
{
//Put up an alert box indicating user to wait while data is loading.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Data is Loading"
message:@"Please wait while data is being refreshed."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:FALSE];
NSLog(@"Refresh Data");
self.txtCustomerSearch.text =@"";
[self cleanUPPreviousLabels];
NSLog(@"hit in willpresenet alertview at 221");
self.refreshActIndicator.hidden = NO;
[self.refreshActIndicator startAnimating];
NSLog(@"Dispatching");
//Disable the view and all the other controls
self.txtCustomerSearch.userInteractionEnabled =NO;
self.txtCustomerSearch.enabled =NO;
self.btnSearch.enabled =NO;
self.btnSearch.userInteractionEnabled = NO;
self.scrollView.userInteractionEnabled = NO;
//self.view.userInteractionEnabled =NO;
self.chkButton.enabled = NO;
[self deletePreviousValues];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSLog(@"Getting customer values");
[self getAllCustomerValues];
NSLog(@"Got customer values");
NSError *nwerror = nil;
if (![self.secondMOC save:&nwerror])
{
NSLog(@"209 Failed to save second MOC");
}
else
{
//NSLog(@"saved success");
}
self.txtCustomerSearch.userInteractionEnabled = YES;
self.txtCustomerSearch.enabled =YES;
self.btnSearch.enabled =YES;
self.btnSearch.userInteractionEnabled = YES;
self.scrollView.userInteractionEnabled = YES;
self.view.userInteractionEnabled =YES;
self.chkButton.enabled = YES;
[self.refreshActIndicator stopAnimating];
NSLog(@"Saved");
});
NSLog(@"Dispatched");
}
Why is alert view not showing up immediately. OR Why is my UIThread( i am assuming my main thread) not showing the alertview immediately. Any help would be great. I am trying to get to solve this past 5 hours. So please help. It is in iOS 6.0 and iPad in-house project. If you need more information, please ask. Thanks.