Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Attention when moving asynchronously UI-changing code to a background thread: Notifications sent using the `NSNotificationCenter.defaultCenter()` must be sent on the main thread. Otherwise you will receive a warning like this: "This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and w…
func postMainThreadNotificationName(name: String, object: AnyObject?, userInfo: [NSObject : AnyObject]?) {
dispatch_async(dispatch_get_main_queue(), {
NSNotificationCenter.defaultCenter().postNotificationName(name, object: object, userInfo: userInfo)
})
}
@JaNd3r

This comment has been minimized.

Copy link
Owner Author

commented Nov 5, 2015

Complete console log message:

    This application is modifying the autolayout engine from a background thread,
    which can lead to engine corruption and weird crashes.
    This will cause an exception in a future release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.