Runtime

作者: 西门魏国 | 来源:发表于2015-03-29 22:53 被阅读949次

    runtime 

    1,支持nil发送消息

    2,支持selector为空(就是方法为空,selector也能识别)

    runtime selector方法识别

    1,在当前class找

    2,在父类class找,->直到nsobject类

    3,动态方法解析,向当前类发送 resolveInstanceMethod: 信号,检查是否动态向该类添加了方法

    4,快速消息转发,检查该类是否实现了 forwardingTargetForSelector: 方法,若实现了则调用这个方法。若该方法返回值对象非nil或非self,则向该返回对象重新发送消息。

    5,标准消息转发,runtime发送methodSignatureForSelector:消息获取Selector对应的方法签名。返回值非空则通过forwardInvocation:转发消息,返回值为空则向当前对象发送doesNotRecognizeSelector:消息,程序崩溃退出。

    相关文章

      网友评论

      本文标题:Runtime

      本文链接:https://www.haomeiwen.com/subject/fsonxttx.html