How to reference Swift Playground itself?
I am trying to use NSNotificationCenter
to observe some variable, but i do not know how to implement it on Playground
.
Here is my code. I just want to observe the timeout
variable, but without the willSet
method.
var timeout = false
var cont: Int8 = 1
NSNotificationCenter.defaultCenter().addObserver(self, forKeyPath: timeout, options: NSKeyValueObservingOptions.New, context: &cont)
Is there any way to do it on playground?
There is KVO playground on gitHub, try this one https://github.com/rectalogic/KVOPlayground
or you might interested in this one: How to reference Swift Playground itself?