简体   繁体   English

Objective-C代表类型

[英]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> delegatedelegate的类型应该是什么? So running po delegete or po self.delegate in LLDB, what is the expected outcome? 那么在LLDB中运行po delegetepo 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM