如何引用 Swift Playground 本身?
我正在尝试使用
NSNotificationCenter
来观察某些变量,但我不知道如何在 Playground
上实现它。
这是我的代码。我只想观察
timeout
变量,但没有 willSet
方法。
var timeout = false
var cont: Int8 = 1
NSNotificationCenter.defaultCenter().addObserver(self, forKeyPath: timeout, options: NSKeyValueObservingOptions.New, context: &cont)
有什么办法可以在操场上做吗?
gitHub 上有 KVO Playground,试试这个 https://github.com/rectalogic/KVOPlayground
或者您可能对此感兴趣: 如何引用 Swift Playground 本身?