<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on LWX Blog</title><link>http://lwx.ac.cn/post/</link><description>Recent content in Posts on LWX Blog</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>©LWX</copyright><lastBuildDate>Thu, 17 Feb 2022 12:11:39 +0800</lastBuildDate><atom:link href="http://lwx.ac.cn/post/index.xml" rel="self" type="application/rss+xml"/><item><title>iOS Runtime探究系列1 - 消息转发底层原理</title><link>http://lwx.ac.cn/post/tech/ios-runtime-messagesend/</link><pubDate>Thu, 17 Feb 2022 12:11:39 +0800</pubDate><guid>http://lwx.ac.cn/post/tech/ios-runtime-messagesend/</guid><description>本篇主要通过对ios 底层库 objc（runtime）的探究，浅析OC中消息转发的过程
[TOC]
1. oc 中的方法调用是如何转化成消息的？ 我们熟知的OC中的方法调用是通过方括号的，如下：
[instance1 testMsgSend] 底层是将这种调用方式转化成消息机制了，这一步是依赖于编译器的，接下来我们通过clang的 -rewrite-objc 来看下编译成C++代码的结果。
​ main.m 文件内容
#import &amp;lt;UIKit/UIKit.h&amp;gt; #import &amp;#34;AppDelegate.h&amp;#34; #import &amp;#34;LWXClass.h&amp;#34; int main(int argc, char * argv[]) { NSString * appDelegateClassName; @autoreleasepool { // Setup code that might create autoreleased objects goes here. appDelegateClassName = NSStringFromClass([AppDelegate class]); LWXClass *instance1 = [[LWXClass alloc] init]; [instance1 testMsgSend]; } return UIApplicationMain(argc, argv, nil, appDelegateClassName); } 下面我们通过clang将.m文件编译成C++文件：
xcrun -sdk iphonesimulator clang -rewrite-objc main.</description></item><item><title>技术文章</title><link>http://lwx.ac.cn/post/tech/tech/</link><pubDate>Tue, 07 Dec 2021 20:39:47 +0800</pubDate><guid>http://lwx.ac.cn/post/tech/tech/</guid><description>iOS 相关 iOS Runtime探究系列1 - 消息转发底层原理</description></item></channel></rss>