Latest 0.0.1
Homepage https://github.com/Nikita2k/SwiftDispatchAfter
License Apache
Platforms ios 8.0

SwiftDispatchAfter is small code snippet for calling dispatch_after in Swift.

The idea belongs to Matt Neuburg (http://stackoverflow.com/users/341994/matt). Added some covinience methods.

Usage

  1. add use_frameworks! to your Podfile
  2. add pod 'SwiftDispatchAfter' && run pod install
  3. add import SwiftDispatchAfter to your swift file
  4. ???
  5. Profit!

Now you can use swift function instead of dispatch_after.

This will call closure on main_queue:

    delay(2.seconds) {

        NSLog("I will be called in 2 seconds")

    }

And this will call closure on backgroud queue:

    delay(2.seconds, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {

        NSLog("Not on main thread")

    }       

List of supported time intervals:

  • second(s)
  • minute(s)
  • hour(s)

Latest podspec

{
    "name": "SwiftDispatchAfter",
    "version": "0.0.1",
    "summary": "SwiftDispatchAfter is small code snippet so simplify dispatch_after in Swift",
    "homepage": "https://github.com/Nikita2k/SwiftDispatchAfter",
    "license": "Apache",
    "authors": "Nikita Took",
    "source": {
        "git": "https://github.com/Nikita2k/SwiftDispatchAfter.git",
        "tag": "0.0.1"
    },
    "source_files": "Classes/*.swift",
    "platforms": {
        "ios": "8.0"
    }
}

Pin It on Pinterest

Share This