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