сообщение – это всего лишь строка с информацией о том что и кому отправить, и её можно переслать по сети.
Если вы пишете:
id i = [obj do: something];
1) шлётся сообщение (вызов функции obj_msgSend с получателем, селектором – строкой с именем сообщения, – и остальными аргументами);
2) в dispatch table иерархии классов ищется функция, соответствующая этому селектору, i. e. «method», если её нет, вызывается — forwardingTargetForSelector: или — forwardInvocation:, чтобы переслать сообщение, или если их не реализовали — doesNotRecognizeSelector: с исключением.
3) вызывается функция, с реализацией (у этого или, в случае пересылки, иного класса)
4) obj_msgSend возвращает значение
Именно этим способом работают прокси – они отвечают на сообщения, но не реализуют своих методов.
неужели никто не смотрел?
When it encounters a method invocation, the compiler might generate a call to any of several functions to perform the actual message dispatch, depending on the receiver, the return value, and the arguments. You can use these functions to dynamically invoke methods from your own plain C code, or to use argument forms not permitted by NSObject’s perform… methods. These functions are declared in /usr/include/objc/objc-runtime.h.
objc_msgSend sends a message with a simple return value to an instance of a class.
objc_msgSend_stret sends a message with a data-structure return value to an instance of a class.
objc_msgSendSuper sends a message with a simple return value to the superclass of an instance of a class.
objc_msgSendSuper_stret sends a message with a data-structure return value to the superclass of an instance of a class.
Если вы пишете:
id i = [obj do: something];
1) шлётся сообщение (вызов функции obj_msgSend с получателем, селектором – строкой с именем сообщения, – и остальными аргументами);
2) в dispatch table иерархии классов ищется функция, соответствующая этому селектору, i. e. «method», если её нет, вызывается — forwardingTargetForSelector: или — forwardInvocation:, чтобы переслать сообщение, или если их не реализовали — doesNotRecognizeSelector: с исключением.
3) вызывается функция, с реализацией (у этого или, в случае пересылки, иного класса)
4) obj_msgSend возвращает значение
Именно этим способом работают прокси – они отвечают на сообщения, но не реализуют своих методов.
неужели никто не смотрел?
When it encounters a method invocation, the compiler might generate a call to any of several functions to perform the actual message dispatch, depending on the receiver, the return value, and the arguments. You can use these functions to dynamically invoke methods from your own plain C code, or to use argument forms not permitted by NSObject’s perform… methods. These functions are declared in /usr/include/objc/objc-runtime.h.
objc_msgSend sends a message with a simple return value to an instance of a class.
objc_msgSend_stret sends a message with a data-structure return value to an instance of a class.
objc_msgSendSuper sends a message with a simple return value to the superclass of an instance of a class.
objc_msgSendSuper_stret sends a message with a data-structure return value to the superclass of an instance of a class.