Open the log

  • inlog_and_fill_cacheIn the delta function, we saw thatobjcMsgLogEnabledThis variable, of course, isobjcMsgLogEnabled = true, the system can printmsgSendThe log
  • We find where it’s assigned

  • Obviously we callinstrumentObjectMessageSendsMethod can be assigned to it

  • Location where logs are stored/tmp/msgSends-%d

use

  • Currently only inmacThe simulator hasn’t found a solution yet
  • The statementextern void instrumentObjcMessageSends(BOOL flag);
extern void instrumentObjcMessageSends(BOOL flag);

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        instrumentObjcMessageSends(YES);
        WLWPerson *person = [WLWPerson alloc];
        [WLWPerson say666];
        instrumentObjcMessageSends(NO);
        NSLog(@"Hello, World!");
    }
    return 0;
}
Copy the code
  • And then in the systemtmpdirectory

  • You can view the corresponding log

  • You can see the wholeobjc_msgSendprocess
  • resolveClassMethod -> resolveInstanceMethod -> forwardingTargetForSelector->methodSignatureForSelector -> resolveInstanceMethod -> doesNotRecognizeSelector