Skip to content

Instantly share code, notes, and snippets.

@paskowski
Last active July 3, 2019 09:01
Show Gist options
  • Save paskowski/d29535e38aebf564033b7efb8f33fa62 to your computer and use it in GitHub Desktop.
Save paskowski/d29535e38aebf564033b7efb8f33fa62 to your computer and use it in GitHub Desktop.
import Foundation
class AsyncOperation: Operation {
public enum State: String {
case ready, executing, finished
fileprivate var keyPath: String {
return "is" + rawValue.capitalized
}
}
public var state = State.ready {
willSet {
willChangeValue(forKey: state.keyPath)
willChangeValue(forKey: newValue.keyPath)
}
didSet {
didChangeValue(forKey: oldValue.keyPath)
didChangeValue(forKey: state.keyPath)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment