【发布时间】:2012-02-07 20:38:27
【问题描述】:
我刚刚开始了一个运行 Xcode 4.2.1 和 iOS5 SDK 的新项目。该项目是使用 ARC 设置的。我正在尝试通过执行 [tabBarController setDelegate:self]; 将 AppDelegate 设置为 UITabBarController 的代表,如果我这样做,我会收到一条警告消息:
warning: Semantic Issue: Sending 'AppDelegate *const __strong' to parameter of incompatible type 'id<UITabBarControllerDelegate>'
好吧,我设置了我的 AppDelegate 以符合 UITabBarControllerDelegate
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>
很好,警告消失了。
我现在遇到另一个错误。在视图控制器中,我想获取 AppDelegate,所以我这样做:AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 但这会显示警告:
warning: Semantic Issue: Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id<UIApplicationDelegate>'
但如果我删除我的 AppDelegate 符合 UITabControllerDelegate 协议,我的第二个警告就会消失。
很奇怪的行为,Cocoa 专家有什么用?
【问题讨论】:
标签: objective-c cocoa-touch delegates automatic-ref-counting uiapplicationdelegate