iOS: What is the processing overhead in invoking an Objective-C method?

守給你的承諾、 提交于 2019-12-05 12:23:40

Objective-C method resolution is dynamic. In other languages such as C or C++, a function call is set at compile time, essentially as a jump to the address that contains the function. In Objective-C however, method calls are implemented as 'sending messages' which don't work in the same way. There is a lookup process involved instead of a hardcoded jump.

This lookup process as an overhead associated with locating the address of the method to run. It is very optimised, but for certain types of code the overhead can cause performance issues.

Mike Ash gives a great writeup on what happens with Objective-C messaging if you're interested in additional detail.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!