'swift 4.0 dispatch_semaphore_wait with DISPATCH_TIME_FOREVER
dispatch_semaphore_wait(writeSemaphore!, DISPATCH_TIME_FOREVER)
gives error for DISPATCH_TIME_FOREVER i.e.
Cannot convert value of type 'Int' to expected argument type 'dispatch_time_t' (aka 'UInt64')
Een assigning a value DispatchTime.distantFuture could not help.
Can any one let me know what could be the value of dispatch_time_t(timeout)
Solution 1:[1]
I'll go for:
writeSemaphore!.wait(timeout: .distantFuture)
But you should improve you code, by making sure your optional isn't nil. Go for a guard as follows:
guard let writeSemaphore = writeSemaphore else { return }
writeSemaphore.wait(timeout: .distantFuture)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stéphane de Luca |
