MBProgressHUD crash in [MBProgressHUD done]

519 Views Asked by At

I am using the MBProgressHUD in my app. I always receive crash logs about it by crash reporter system, just like that

Cloudoc-Patient -[MBProgressHUD done] (MBProgressHUD.m:376)
1devices
App Version: -
Thread 0 Crashed:
0 libobjc.A.dylib 0x197350000 + 113616
1 Cloudoc-Patient -[MBProgressHUD done] (MBProgressHUD.m:376)
2 UIKit 0x18a0f0000 + 295108
3 UIKit 0x18a0f0000 + 294860
4 QuartzCore 0x189a2c000 + 87596
5 libdispatch.dylib 0x1979d4000 + 6484
6 libdispatch.dylib 0x1979d4000 + 25100
7 CoreFoundation 0x18555c000 + 914756
8 CoreFoundation 0x18555c000 + 906732
9 CoreFoundation 0x18555c000 + 36724
10 GraphicsServices 0x18efb4000 + 46844
11 UIKit 0x18a0f0000 + 486804
12 Cloudoc-Patient main (main.m:23)
13 libdyld.dylib 0x197a00000 + 10760

In the Xcode-->Organizer-->Crashes, after locating the code, it like thatcrash code I use it just like that in a UIViewController category

- (void)showLoadingHUD {
if(!self.view)
{
    return;
}
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.removeFromSuperViewOnHide = YES;
hud.mode = MBProgressHUDModeIndeterminate;
}
- (void)hideHUD {
if(!self.view)
{
    return;
}
[MBProgressHUD hideAllHUDsForView:self.view animated:NO];
}

Can anyone help me?

1

There are 1 best solutions below

1
OMGHaveFun On

My way to use:

@property (strong, nonatomic) MBProgressHUD *hud;

And then

#pragma mark - DataManager -
- (void)getData {

if (![self.hud isHidden]) {
    [self.hud hideAnimated:YES];
}
self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

[XXXDataManager xxxWithRequestModel:self.xxxRequestModel completion:^(BOOL success, id  _Nullable result, NSError * _Nullable error) {

    [self.hud hideAnimated:YES];

    if (success) {
        ...
    }
    else {
        ...
    }
}];}