简体   繁体   中英

Changing UI from a background thread

I getting an error that Iam changing the autolayout engine from a background thread , is there's a way to know which block of code makes this warning ? or I just have to search for it by myself ?? Thank you.

Probably there is a better answer but I would start by putting

for Swift:

assert(NSThread.isMainThread(), "Expected code to be called on main thread");

for Objective-C:

NSAssert([NSThread isMainThread], @"Expected code to be called on main thread"); 

to all sections of your code you're suspicious about.

This way app will crash if you're doing that code not on main thread.


Is this error an error or is it an exception? If it is exception you can try to catch it using exception breakpoint like here: How to debug “Collection was mutated while being enumerated” errors and like, when Xcode does not provide me with enough information? ?


After having looked at your exact message looks like what you need is:

This code PSPDFUIKitMainThreadGuard causes assertions on UIKit access outside the main thread

taken from iOS9 - This application is modifying the autolayout engine from a background thread — where? .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM