Skip to content

Instantly share code, notes, and snippets.

@mminer
Last active October 18, 2017 04:54
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 mminer/b5e42150736b61d5959d to your computer and use it in GitHub Desktop.
Save mminer/b5e42150736b61d5959d to your computer and use it in GitHub Desktop.
Swift function for posting notifications on main thread.
// 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