Skip to content

Instantly share code, notes, and snippets.

@Kaelten
Last active August 29, 2015 14:02
Show Gist options
  • Save Kaelten/7914a8128eca45f081b3 to your computer and use it in GitHub Desktop.
Save Kaelten/7914a8128eca45f081b3 to your computer and use it in GitHub Desktop.
Simple Swift @synchronized Helper
// A simple replacement for Obj-C's @synchronized keyword, currently seems to cause compiler error if lock is an object array.
func synced(lock: AnyObject, closure: () -> ()) {
objc_sync_enter(lock)
closure()
objc_sync_exit(lock)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment