Ios AppDelegate没有可见接口声明选择器

Ios AppDelegate没有可见接口声明选择器,ios,class-method,appdelegate,Ios,Class Method,Appdelegate,AppDelegate.h: @interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> + (MBProgressHUD *)showGlobalProgressHUDWithTitle:(NSString *)title; 在AppDelegate.m中的其他方法中: + (MBProgressHUD *)showGlobalProgressHUDWithTi

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;
}
[self showGlobalProgressHUDWithTitle:@"Checking for Updates"];  //No visible interface for AppDelegate declares the selector 'showGlobalProgressHUDWithTitle:'

为什么??界面中的其他方法是可见的,但为什么这个方法不可见呢?这与类方法有关吗?

您正在从对象实例(self)调用类方法


在方法声明和实现中,将+更改为-,然后进行排序。

+是类方法,-是实例方法。您不在self上执行该方法,而是在AppDelegate上执行它。您可能希望将定义更改为-。@StefanH,这很有意义,但为什么我也不能(从另一个类)执行此操作:AppDelegate AppDelegate=(AppDelegate)[[UIApplication sharedApplication]delegate];[appDelegate showGlobalProgressHUDWithTitle:@“任意”];因为
[[UIApplication sharedApplication]delegate]
返回的是
AppDelegate
的实例,而不是类本身。要调用类方法,需要执行
[AppDelegate classMethodName]