Skip to content

Instantly share code, notes, and snippets.

View dars's full-sized avatar

Devlin dars

  • code4soul
  • Taiwan,Taipei
View GitHub Profile
@dars
dars / BackgroundTask.swift
Created September 8, 2017 13:01 — forked from phatmann/BackgroundTask.swift
Encapsulate iOS background tasks in a Swift class
class BackgroundTask {
private let application: UIApplication
private var identifier = UIBackgroundTaskInvalid
init(application: UIApplication) {
self.application = application
}
class func run(application: UIApplication, handler: (BackgroundTask) -> ()) {
// NOTE: The handler must call end() when it is done