Skip to content
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

Open
christinalau opened this issue Sep 19, 2016 · 6 comments
Open

Support Swift 3.0? #97

christinalau opened this issue Sep 19, 2016 · 6 comments

Comments

@christinalau
Copy link

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.

@xrelative
Copy link

+1

@drewpitchford
Copy link

Yes this would be great. The Obj C version as well. Xcode 8 doesn't like
_preferredStatusBarStyle

Need to replace it with self.preferredStatusBarStyle

@robertbabington
Copy link

robertbabington commented Sep 26, 2016

@christinalau I managed to get performClosureAfterDelay working by changing it as follows:

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
}

#98

@christinalau
Copy link
Author

@robertbabington Thank you, works great 👍

@axmav
Copy link

axmav commented Sep 30, 2016

+1

@rob212
Copy link

rob212 commented Oct 5, 2016

Good Swift fix @robertbabington thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants