在 Objective-C 中创建委托(delegate)时,假定委托(delegate):id <DelegateName> delegate
, 什么是 delegate
的类型应该是?所以运行po delegete
或 po self.delegate
在 LLDB 中,预期结果是什么?
如果其预期为 DelegateName
,而不是您将如何手动更改它?
编辑:
@protocol NavigationBarDelegate @选修的 - (void)titleViewClicked:(BOOL)titleClicked; @结束
po
LLDB 中的输出:
(lldb) po self.delegate
(objc_object *) $1 = 0x073d0840 <UINavigationController: 0x73d0840>
因此,委托(delegate)被发送到 UINavigationController
而不是预期的类。
最佳答案
类型是id
所以它可以是任何 Objective-C 对象。 <DelegateName>
表示法意味着该对象将符合 DelegateName
协议(protocol),但这并不影响它的类型。
关于iphone - Objective-C 委托(delegate)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11776607/