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);

}

你可能感兴趣的:(clang oc文件)