-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Swift 3.0? #97
Comments
+1 |
Yes this would be great. The Obj C version as well. Xcode 8 doesn't like Need to replace it with |
@christinalau I managed to get func performClosureAfterDelay(_ seconds : Double, closure: (() -> ())?) -> CWDelayedClosureHandle? {
guard closure != nil else {
return nil
}
var closureToExecute : (() -> ())! = closure // copy?
var delayHandleCopy : CWDelayedClosureHandle! = nil
let delayHandle : CWDelayedClosureHandle = {
(cancel : Bool) -> () in
if !cancel && closureToExecute != nil {
DispatchQueue.main.async(execute: closureToExecute)
}
closureToExecute = nil
delayHandleCopy = nil
}
delayHandleCopy = delayHandle
let delay = Int64(Double(seconds) * Double(NSEC_PER_SEC))
let after = DispatchTime.now() + Double(delay) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: after) {
if delayHandleCopy != nil {
delayHandleCopy(false)
}
}
return delayHandleCopy
} |
@robertbabington Thank you, works great 👍 |
+1 |
Good Swift fix @robertbabington thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, can we have a version that supports XCode 8 and Swift 3.0 please. The code performClosureAfterDelay is not working and I don't know how to fix it. Thanks.
The text was updated successfully, but these errors were encountered: