Mac开发——报错:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'


完整报错

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!' terminating with uncaught exception of type NSException

原因

所有AppKit / GUI调用都需要在主线程中进行,无法在其他线程执行。

解决办法

在主线程执行代码,如果该代码在其他子线程当中,则可以用dispatch_async(dispatch_get_main_queue(), ^{})方法调起主线程,将代码写在其中

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM