-2

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, actually 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?

unknowncoder
  • 132
  • 1
  • 10

1 Answers1

2

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?

Community
  • 1
  • 1
F. Suyuti
  • 327
  • 3
  • 18