What is the Swift equivalent to Objective-C’s “@synchronized”?

You can use GCD. It is a little more verbose than @synchronized, but works as a replacement:

let serialQueue = DispatchQueue(label: "com.test.mySerialQueue")
serialQueue.sync {
    // code
}

Leave a Comment