- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
}
在touchesBegan
方法设置断点,控制台输入thread backtrace all
,获取调用流程(调用顺序为打印出来的内容,从下往上执行:
1、线程“com.apple.main-thread”
从“dyld`start + 520”开始执行。
2、线程“com.apple.uikit.eventfetch-thread”
从“libsystem_kernel.dylib`__workq_kernreturn + 8”开始执行。
(lldb) thread backtrace all
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
* frame #0: 0x0000000104b81e14 Demo`-[ViewController touchesBegan:withEvent:](self=0x000000015ff04c90, _cmd="touchesBegan:withEvent:", touches=1 element, event=0x0000600000730cc0) at ViewController.m:32:1
frame #1: 0x0000000184dbd96c UIKitCore`forwardTouchMethod + 316
frame #2: 0x0000000184dcd65c UIKitCore`-[UIWindow _sendTouchesForEvent:] + 548
frame #3: 0x0000000184dcf36c UIKitCore`-[UIWindow sendEvent:] + 4332
frame #4: 0x0000000184da70fc UIKitCore`-[UIApplication sendEvent:] + 784
frame #5: 0x0000000184e3559c UIKitCore`__dispatchPreprocessedEventFromEventQueue + 7720
frame #6: 0x0000000184e37620 UIKitCore`__processEventQueue + 6764
frame #7: 0x0000000184e2f540 UIKitCore`__eventFetcherSourceCallback + 184
frame #8: 0x0000000180362234 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #9: 0x0000000180362134 CoreFoundation`__CFRunLoopDoSource0 + 204
frame #10: 0x00000001803614c4 CoreFoundation`__CFRunLoopDoSources0 + 256
frame #11: 0x000000018035ba18 CoreFoundation`__CFRunLoopRun + 744
frame #12: 0x000000018035b218 CoreFoundation`CFRunLoopRunSpecific + 572
frame #13: 0x000000018c25f60c GraphicsServices`GSEventRunModal + 160
frame #14: 0x0000000184d88a98 UIKitCore`-[UIApplication _run] + 992
frame #15: 0x0000000184d8d634 UIKitCore`UIApplicationMain + 112
frame #16: 0x0000000104b82080 Demo`main(argc=1, argv=0x000000016b27dc88) at main.m:21:12
frame #17: 0x0000000104d9dcd8 dyld_sim`start_sim + 20
frame #18: 0x0000000104f1108c dyld`start + 520
thread #5, name = 'com.apple.uikit.eventfetch-thread'
frame #0: 0x00000001cc055fcc libsystem_kernel.dylib`mach_msg_trap + 8
frame #1: 0x00000001cc056430 libsystem_kernel.dylib`mach_msg + 72
frame #2: 0x000000018036176c CoreFoundation`__CFRunLoopServiceMachPort + 368
frame #3: 0x000000018035bb78 CoreFoundation`__CFRunLoopRun + 1096
frame #4: 0x000000018035b218 CoreFoundation`CFRunLoopRunSpecific + 572
frame #5: 0x0000000180827828 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
frame #6: 0x0000000180827ae0 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 88
frame #7: 0x0000000184e3f01c UIKitCore`-[UIEventFetcher threadMain] + 472
frame #8: 0x0000000180851578 Foundation`__NSThread__start__ + 792
frame #9: 0x00000001cc0b16c8 libsystem_pthread.dylib`_pthread_start + 116
thread #9
frame #0: 0x00000001cc057ce4 libsystem_kernel.dylib`__workq_kernreturn + 8
(lldb)