Created
January 29, 2018 21:29
-
-
Save olbrichj/294aca0f8025876d77d9f7505321befa 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 OperationObserver: NSObject { | |
init(operation: AsyncOperation) { | |
super.init() | |
operation.addObserver(self, forKeyPath: "finished", options: .new, context: nil) | |
} | |
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { | |
guard let key = keyPath else { | |
return | |
} | |
switch key { | |
case "finished": | |
print("done") | |
default: | |
print("doing") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment