Np, you can't. NSObject
does not a define a property called view
. But you can pass the view controller to the object:
- (void)showHudWithMessage:(NSString*)text fromViewController:(UIViewController *)viewController
{
HUD = [[MBProgressHUD alloc] initWithView:viewController.view];
[viewController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = text;
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}