How can I programmatically dismiss a UIAlertController
<p>I need to programmatically dismiss a UIAlertController that I'm using as a "please wait" message. I can present the alert without problem but when it comes to dismissing the alert, 50% of the time it dismisses and the other 50% it doesn't, forcing me to restart the app just to continue using it. Any ideas how to dismiss the alert with 100% consistency?</p>

<pre><code>//loadingAlert is a UIAlertController declared in the .h file
//present the Alert
loadingAlert = [UIAlertController alertControllerWithTitle:@"Loading..." message:@"Please wait while we fetch locations" preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:loadingAlert animated:YES completion:nil];

//parse JSON file
_listOfAcquisitions = nil;
MNSHOW_NETWORK_ACTIVITY(YES);
NSString *WebServiceURL = [NSString stringWithFormat:@"JSON URL", _search];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
    NSDictionary *dictionary = [JSONHelper loadJSONDataFromURL:WebServiceURL];
    dispatch_async(dispatch_get_main_queue(), ^{
        _listOfAcquisitions = [NSMutableArray array];
        for (NSDictionary *oneEntry in dictionary) {
            Acquisitions *acqu = [[Acquisitions alloc] init];

            if([oneEntry objectForKey:@"ADDRESS1"] == (NSString *)[NSNull null]){acqu.ADDRESS1 = @"";}
            else {acqu.ADDRESS1 = [oneEntry objectForKey:@"ADDRESS1"];}

            if([oneEntry objectForKey:@"STATEABBR"] == (NSString *)[NSNull null]){acqu.STATEABBR = @"";}
            else {acqu.STATEABBR = [oneEntry objectForKey:@"STATEABBR"];}

            if([oneEntry objectForKey:@"TOWN"] == (NSString *)[NSNull null]){acqu.TOWN = @"";}
            else {acqu.TOWN = [oneEntry objectForKey:@"TOWN"];}

            if([oneEntry objectForKey:@"ZIPCODE"] == (NSString *)[NSNull null]){acqu.ZIPCODE = @"";}
            else {acqu.ZIPCODE = [oneEntry objectForKey:@"ZIPCODE"];}

            [_listOfAcquisitions addObject:acqu];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            MNSHOW_NETWORK_ACTIVITY(NO);

            [self refreshAnnotations:self];

        });
    });
});
//finally dismiss the alert...
[loadingAlert dismissViewControllerAnimated:YES completion:nil];
}
</code></pre>