[英]Objective-C Delegate Type
When creating delegates in Objective-C, assume delegate: id <DelegateName> delegate
, what is the delegate
's type supposed to be? 在Objective-C中创建委托时,假定委托为: id <DelegateName> delegate
, delegate
的类型应该是什么? So running po delegete
or po self.delegate
in LLDB, what is the expected outcome? 那么在LLDB中运行po delegete
或po self.delegate
,预期结果是什么?
If its expected to be DelegateName
, and it wasn't how would you change it manually? 如果期望它是DelegateName
,那么您将不会手动更改它吗?
EDIT: 编辑:
@protocol NavigationBarDelegate @optional - (void)titleViewClicked:(BOOL)titleClicked; @protocol NavigationBarDelegate @可选-(void)titleViewClicked:(BOOL)titleClicked; @end @结束
po
output in LLDB: LLDB中的po
输出:
(lldb) po self.delegate
(objc_object *) $1 = 0x073d0840 <UINavigationController: 0x73d0840>
As a result, the delegate is being sent to a UINavigationController
as opposed to the intended class. 结果,委托被发送到UINavigationController
而不是预期的类。
The type is id
so it can be any Objective-C object. 类型是id
因此它可以是任何 Objective-C对象。 The <DelegateName>
notation means that the object will conform to the DelegateName
protocol, but that does not affect its type. <DelegateName>
表示该对象将符合DelegateName
协议,但这不会影响其类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.