objective c runtime 分享2
TRANSCRIPT
Review1. + (BOOL)resolveInstanceMethod:(SEL)name; 2. - (id)forwardingTargetForSelector:(SEL)aSelector;
3. -(NSMethodSignature*)methodSignatureForSelector:(SEL)aSelector; - (void)forwardInvocation:(NSInvocation *)anInvocation;
Message
reciver 是要運⾏行這個 Method 的 Object message 則是要被運⾏行的 Method name
ex: [normalObject invoke]; [NormalObject randomIntegerValue];
Messagecompiler 只會將 Method 轉化為
[normalObject invoke]; to objc_msgSend(normalObject, @selector(invoke));
Message
[NormalObject randomIntegerValue]; to objc_msgSend([NormalObject class], @selector(randomIntegerValue));
Message1. It first finds the procedure (method implementation) that the selector refers to. Since the same method can be implemented differently by separate classes, the precise procedure that it finds depends on the class of the receiver.
Message2. It then calls the procedure, passing it the receiving object (a pointer to its data), along with any arguments that were specified for the method.