Skip to content

Instantly share code, notes, and snippets.

@JaNd3r
Last active December 10, 2018 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaNd3r/6bc6f1fa3deae3d4f607 to your computer and use it in GitHub Desktop.
Save JaNd3r/6bc6f1fa3deae3d4f607 to your computer and use it in GitHub Desktop.
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
Copy link
Author

JaNd3r 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