Getting a “This application is modifying the autolayout engine from a background thread” error?

后端 未结 21 1614
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 15:52

Been encountering this error a lot in my OS X using swift:

\"This application is modifying the autolayout engine from a background thread, which can

21条回答
  •  有刺的猬
    2020-11-22 16:29

    You get similar error message while debugging with print statements without using 'dispatch_async' So when you get that error message, its time to use

    Swift 4

    DispatchQueue.main.async { //code }
    

    Swift 3

    DispatchQueue.main.async(){ //code }
    

    Earlier Swift versions

    dispatch_async(dispatch_get_main_queue()){ //code }
    

提交回复
热议问题