I am trying to do some work in thread for which I am using the MBProgressHUD. When I try to do the following code, it is crashing.
if ([database databaseNeedsMigration]) {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.labelText = @"Upgrading Data";
HUD.detailsLabelText = @"Just relax";
HUD.mode = MBProgressHUDModeAnnularDeterminate;
[self.view addSubview:HUD];
HUD.taskInProgress = YES;
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[HUD showAnimated:YES whileExecutingBlock:^{
[database migrateDatabase];
} onQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0) completionBlock:^{
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}];
}
However when I try to add a selector to MBProgressHUD with a sleep in the function it works.