2014-02-17 59 views
-4

AppDelegate.h文件包含在該行的頂部以下:<>在iOS類頭中的含義是什麼?

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

當前類是AppDelegate這是UIResponder一個子類。 UIApplicationDelegate與當前課程有什麼關係?

+0

其說,AppDelegate中迴應這些協議(UIAppDelegate協議) – santhu

回答

5

它宣佈,類符合UIApplicationDelegate協議。

一個Objective-C協議類似於Java接口:它可以聲明方法簽名,但它不能提供的方法實現。

編譯器會警告你,如果你@implementation缺少任何協議的@required方法。 Xcode將自動完成協議的任何方法(@required@optional)。

您可以用逗號分隔聲明符合多種協議。例如:

@interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> 

閱讀Cocoa Core Competencies: ProtocolProgramming with Objective-C: Working with Protocols

+0

是否存在單證這說明了什麼<>是什麼意思?在其他語言中有什麼相似之處? –

+0

我已經更新了我的答案。 –

相關問題