update UIAlert from main thread

hello,


I have the following code:


    UIAlertAction* cacheAreaInformation = [UIAlertAction
                                           actionWithTitle:@"Cache Area Information"
                                           style:UIAlertActionStyleDefault
                                           handler:^(UIAlertAction * action)
                                           {
                                            [alert dismissViewControllerAnimated:YES completion:nil];
                                               _cachingProgressAlert = [UIAlertController alertControllerWithTitle:@"Caching Area Information" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
                                               [_cachingProgressAlert.view addSubview:[self createProgressBar: _cachingProgressAlert]];
                                               [self presentViewController:_cachingProgressAlert animated:YES completion:nil];
                                               _cachingProgressAlert.title = [NSString stringWithFormat:@"downloading %@ entries", @"fdsfsda"];
                                            dispatch_async(dispatch_get_main_queue(), ^{
                                            [self.voithos repopulateOfflineDB];
                                            });
                                           }];


- (void)didDownloadNearbyEntries: (NSString*) totalNearbyEntries{
    [self performSelectorOnMainThread:@selector(updateProgressBar:) withObject:[NSString stringWithFormat:@"downloaded %@ entries", totalNearbyEntries] waitUntilDone:NO];
}


- (void)updateProgressBar: (NSString*)message {
    _cachingProgressAlert.title = message;
}


As you see, I create an UIAlertController and then update its title from a delegate method. The controller is created and I can see the initial title but I can not see any updates from the delegate method. The method is verified that it is called, but the title of the controller is not.

If I update the alert controller from the background, thte title is updated but I get the warning that I should not do that and that in future versions I will get an exception.

update UIAlert from main thread
 
 
Q