2019-12-18a few seconds read (About 38 words)How to sync an async function in SwiftIssue #547 1234567891011121314func sync<T>(_ work: (@escaping ([T]) -> Void) -> Void) -> [T] { let semaphore = DispatchSemaphore(value: 1) var results = [T]() work { values in results = values semaphore.signal() } return results}sync({ completion in service.load(completion)})#swift