AppDelegate.h:
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>
+ (MBProgressHUD *)showGlobalProgressHUDWithTitle:(NSString *)title;
AppDelegate.m:
+ (MBProgressHUD *)showGlobalProgressHUDWithTitle:(NSString *)title {
UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
[MBProgressHUD hideAllHUDsForView:window animated:YES];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
hud.labelText = title;
return hud;
}
在 AppDelegate.m 的 someOtherMethod 中:
[self showGlobalProgressHUDWithTitle:@"Checking for Updates"]; //No visible interface for AppDelegate declares the selector 'showGlobalProgressHUDWithTitle:'
为什么?界面中的其他方法都是可见的,但为什么不是这个呢?它与作为类方法有关吗?