clang oc文件

将oc文件编译为.cpp
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk xxxxx.m

 self.timer1 = [NSTimer timerWithTimeInterval:2.0 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.timer1 forMode:NSRunLoopCommonModes];
static void _I_ViewController_viewDidLoad(ViewController * self, SEL _cmd) {
    ((void (*)(__rw_objc_super *, SEL))(void *)objc_msgSendSuper)((__rw_objc_super){(id)self, (id)class_getSuperclass(objc_getClass("ViewController"))}, sel_registerName("viewDidLoad"));
    ((void (*)(id, SEL, NSTimer *))(void *)objc_msgSend)((id)self, sel_registerName("setTimer1:"), ((NSTimer * _Nonnull (*)(id, SEL, NSTimeInterval, id _Nonnull, SEL _Nonnull, id _Nullable, BOOL))(void *)objc_msgSend)((id)objc_getClass("NSTimer"), sel_registerName("timerWithTimeInterval:target:selector:userInfo:repeats:"), 2., (id _Nonnull)self, sel_registerName("timerAction"), (id _Nullable)__null, ((bool)1)));
    ((void (*)(id, SEL, NSTimer * _Nonnull, NSRunLoopMode _Nonnull))(void *)objc_msgSend)((id)((NSRunLoop * _Nonnull (*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass("NSRunLoop"), sel_registerName("currentRunLoop")), sel_registerName("addTimer:forMode:"), ((NSTimer *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("timer1")), (NSRunLoopMode)NSRunLoopCommonModes);

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。