當調(diào)用[recever message]時拒担,其實執(zhí)行的是id objc_msgSend(id self, SEL op, ...)這個函數(shù)追驴。recever通過isa指針找到當前對象的class,首先到當前class的cache中查找恶复,去過找到怜森,調(diào)用op,如果沒找到就到methodLists中去查找寂玲,如果沒有就到super_class中去查找塔插,如此循環(huán)直到NSObject。如果在NSObject中仍然沒有找到程序不會立即crash拓哟,而是會按照優(yōu)先級執(zhí)行下類三個方法(高優(yōu)先級方法消息轉(zhuǎn)發(fā)成功后不會再執(zhí)行低優(yōu)先級方法)
方案一:+?(BOOL)resolveInstanceMethod:(SEL)sel
? ? ? ? ? ? ? ?+?(BOOL)resolveClassMethod:(SEL)sel
方案二:-?(id)forwardingTargetForSelector:(SEL)aSelector
方案三:-?(NSMethodSignature?*)methodSignatureForSelector:(SEL)aSelector;
? ? ? ? ? ? ? ? -?(void)forwardInvocation:(NSInvocation?*)anInvocation;