Skip to content

Instantly share code, notes, and snippets.

@olbrichj
Created January 29, 2018 21:27
Show Gist options
  • Save olbrichj/b86bdf0386745cc81e5279bbe8e9325e to your computer and use it in GitHub Desktop.
Save olbrichj/b86bdf0386745cc81e5279bbe8e9325e to your computer and use it in GitHub Desktop.
import Foundation
class AsyncOperation: Operation {
override var isAsynchronous: Bool {
return true
}
var _isFinished: Bool = false
override var isFinished: Bool {
set {
willChangeValue(forKey: "isFinished")
_isFinished = newValue
didChangeValue(forKey: "isFinished")
}
get {
return _isFinished
}
}
var _isExecuting: Bool = false
override var isExecuting: Bool {
set {
willChangeValue(forKey: "isExecuting")
_isExecuting = newValue
didChangeValue(forKey: "isExecuting")
}
get {
return _isExecuting
}
}
func execute() {
}
override func start() {
isExecuting = true
execute()
isExecuting = false
isFinished = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment