Warn on calls to UIKit from background threads

前端 未结 3 1497
[愿得一人]
[愿得一人] 2021-01-02 09:58

iOS\'s UIKit is not thread-safe, let us call this fact well known. I know the rule, I\'m careful, but I still get bitten - and every now and then the resulting crash is far

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 10:14

    Personally anytime I open the box to a multithreaded approach I start wrapping ALL interface based calls in performSelectorOnMainThread: so that there is never an issue. If we've already made it to the main there this call shouldn't cause any significant slow down, but if its called from a background thread I can rest easy knowing its safe.

提交回复
热议问题