Last active
July 3, 2019 09:01
-
-
Save paskowski/d29535e38aebf564033b7efb8f33fa62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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