Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 707 Bytes

README.md

File metadata and controls

26 lines (21 loc) · 707 Bytes

How to dispatch after in Swift?

Since Xcode doesn't have the dispatch_after snippet Swift-ready, I decided I was going to see if the kind of ugly looking API could be improved. This is what I came up with.

Usage

The easy way:

dispatch(after: 2) {
    // ... block that will run after 2 seconds
}

you can also specify a custom queue if you like:

dispatch(after: 2, queue: someQueue) {
    // ... block that will run after 2 seconds on someQueue
}

Installation

Just drop dispatch.swift in your project and you're good to go.

I'm on @wesslansimon if you have questions or just intrested in having a cup of coffee.