Last active
October 18, 2017 04:54
-
-
Save mminer/b5e42150736b61d5959d to your computer and use it in GitHub Desktop.
Swift function for posting notifications on main thread.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NSNotificationCenter isn't thread-safe, so this ensures that notifications are posted on the main thread. | |
func postMainThreadNotification(notification: Notification) { | |
DispatchQueue.main.async { NotificationCenter.default.post(notification) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment