Detect UI actions outside of main thread

前端 未结 3 1792
独厮守ぢ
独厮守ぢ 2021-02-01 05:32

Note: This question is related to Warn on calls to UIKit from background threads but does not give an answer on two of the approaches below.

I have a problem where the a

相关标签:
3条回答
  • 2021-02-01 05:58

    Xcode 9 and later

    Xcode 9 introduces a Main thread checker which sniffs for many relevant issues potentially performed out-of-main thread. You can enable this analyser the usual way in your Scheme options along with other runtime analysers.

    Xcode 8.3 and earlier

    Alternative, Xcode-way solution based on steipete's gist – symbolic breakpoint:

    You can easily add breakpoints for some other methods on any UIKit class, like -[UIView setNeedsDisplay] etc.

    0 讨论(0)
  • 2021-02-01 06:04

    Xcode 11/Swift version of @Michi 's answer

    0 讨论(0)
  • 2021-02-01 06:11

    Starting with Xcode 9 Apple integrated an Main Thread Checker in Xcode which is enabled by default if you run you app in with the Xcode debugger.

    It can be disabled/enabled in the scheme configuration under the diagnostics tab.

    0 讨论(0)
提交回复
热议问题