Here's what I think you want:
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
[view addSubview:hud];
[hud showWhileExecuting:@selector(YOUR_TASK) onTarget:YOUR_TARGET withObject:nil animated:YES]; // or NO if you don't want it to be animated
Alternatively, if you want to manage showing and displaying the HUD manually yourself, there's some nice convenience methods for doing that:
// To add HUD to a view
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; // or NO if you don't want it to be animated
// To set HUD text
[hud setLabelText:@"Text"];
// To remove HUD from a view (such as later in the code, after load, etc)
[MBProgressHUD hideHUDForView:view animated:YES];
Where view
is the view you want the HUD added/removed from.
I.e. self.view
on a view controller.