简体   繁体   中英

Objective-C Delegate Type

When creating delegates in Objective-C, assume delegate: id <DelegateName> delegate , what is the delegate 's type supposed to be? So running po delegete or po self.delegate in LLDB, what is the expected outcome?

If its expected to be DelegateName , and it wasn't how would you change it manually?

EDIT:

@protocol NavigationBarDelegate @optional - (void)titleViewClicked:(BOOL)titleClicked; @end

po output in LLDB:

(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.

The type is id so it can be any Objective-C object. The <DelegateName> notation means that the object will conform to the DelegateName protocol, but that does not affect its type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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