Swift 3.1
var sema = DispatchSemaphore(value: 0)
for myString: String in myArray {
doSomething(to: myString, withCompletion: {(_ completion: Bool) -> Void in
string = String + ("Test")
dispatch_semaphore_signal(sema)
})
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
dispatch_release(sema)
}
source
share