为什么AppDelegate从UIResponderinheritance?

我注意到当在Xcode 4.2 beta 4中使用iPhone Master-Detail模板创build一个新项目时,它会:

// AppDelegate.h @interface AppDelegate : UIResponder <UIApplicationDelegate> 

为什么AppDelegateUIResponder而不是NSObjectinheritance?

从转换到故事板发行说明 :

注意:在当前的Xcode模板中,应用程序委托类从UIResponderinheritance。 这样委托实例可以参与响应者链,从而处理应用程序级别的操作。 如果您在现有应用程序中没有使用这种模式,则无需将其应用于故事板。

检查UIResponder的文档。 由于AppDelegate可以响应触摸事件,它实现了UIResponder接口。

我想这是因为它有访问全局撤消pipe理器。

UIResponder是UIKit框架的基类。 UIResponder可以处理事件。

您的AppDelegate类是UIApplicationMain创build的UIApplication的委托类。 AppDelegate符合UIApplicationDelegate协议。

UIResponder类具有获取所有视图将被填充的应用程序焦点的窗口的方法,因此您应该有一个从UIResponderinheritance的类来使窗口成为关键字。

AppDelegate从处理iOS事件的UIResponderinheritance。 UIResponder类为响应和处理事件的对象定义一个接口。

更新:我的答案可能是错的。 我只是在iOS文档中的图像。 但是,它必须是过时的。

除非iOS 5中有新的东西,而且还没有logging,那么我认为这是Xcode 4.2 beta 4模板的一个错字。 在iOS应用程序中,应用程序委托应该NSObject而不是UIResponder ,例如:

 @interface AppDelegate : NSObject <UIApplicationDelegate> 

对于iOS应用程序,在UIKit(对于Cocoa Touch,例如iPhone和iPad)中, UIApplication是响应者链中的最后一个响应者 。

对于Mac OS X应用程序,在应用程序工具包(对于Cocoa,例如Mac)中,应用程序委托是响应者链中的最后一个响应者 。