Objective c——获取协议的父协议列表
Objective C 运行时参考 有函数 class_getSuperclass 用于获取类的超类。有没有类似的东西可以列出协议的直接祖先?
The Objective C runtime reference has the function class_getSuperclass for getting the superclass of a class. Is there anything similar for listing the direct ancestors of a protocol?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不存在祖先这样的东西,因为协议是扩展而不是继承,因此您应该寻找兄弟姐妹。我可以给你的最接近的东西是:
objc_protocol_list
获取协议列表protocol_conformsToProtocol
update 的协议 看来我rtfm 还不够。这是正确的方法:
protocol_copyProtocolList
,其描述为There's no such thing as ancestors, since protocols expand rather than inherit, hence you should look for siblings. The closest thing that I can give you is:
objc_protocol_list
protocol_conformsToProtocol
update it seems i didn't rtfm enough. Here's the proper method:
protocol_copyProtocolList
, which is described as