Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Xcode main thread warning #2533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lacyrhoades
Copy link

Otherwise, reading any UIKit values like .bounds will give a warning:
Main Thread Checker: UI API called on a background thread: -[UIView bounds]


runOnMainQueueWithoutDeadlocking(^{
currentBounds = self.bounds;
});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this by logging:

NSLog(@"Is main thread: %@", [NSThread isMainThread] ? @"YES" : @"NO");

Usually is "yes" but not always.

Otherwise, reading any UIKit values like `.bounds` will give a warning:
Main Thread Checker: UI API called on a background thread: -[UIView bounds]

Taking out debug code
@lacyrhoades lacyrhoades force-pushed the xcode-9-main-thread-checker-fix branch from 401b098 to ae1ed97 Compare November 25, 2017 20:48
@ntnmrndn
Copy link

This causes deadlock for me in layoutSubviews

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants