0

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:'

なんで?インターフェイスの他のメソッドが表示されますが、なぜこれが表示されないのですか?それはクラスメソッドであることに関係がありますか?

4

1 に答える 1

2

オブジェクトインスタンス(自己)からクラスメソッドを呼び出しています。

メソッドの宣言と実装で+を-に変更すると、ソートされます。

于 2012-09-12T06:04:49.807 に答える