[xcode] 紫warningや”This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes”エラー対処方法

“This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes”というエラーがxcodeに表示されまくり、アプリは落ちないものの気持ち悪かったので、対処した。

またxcodeではすごい色の紫warningも出るので、同じく対処

warningの理由としてはメインスレッドで動作させなければならないメソッドを注意してくれるみたい。

スクリーンショット 2017-10-15 16.35.58

indicator.isHidden = true

 DispatchQueue.main.async {
       indicator.isHidden = true
 }

に変更しメインスレッドで処理させるとエラーが表示されなくなる。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です