title: How to reference Swift Playground itself?
body: <p>from <a href="https://stackoverflow.com/questions/24030348/how-create-button-programmatically-in-swift">How to create a button programmatically?</a></p>
  
  <p>self doesn't work in swift playground : </p>
  
  <pre><code>button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
  </code></pre>
  
  <p>error :</p>
  
  <blockquote>
    <p>Playground execution failed: error: :42:13: error: use of
    unresolved identifier 'self'</p>
  </blockquote>
  
  <p>I also tried to create a class with buttonAction method inside it compiles but when I click on the button nothing prints in console</p>
  
  <pre><code>import UIKit
  
  class myself {
  
  
      func buttonAction(sender:UIButton!)
      {
          println("Button tapped")
      }
  
  }
  
  var s = myself()
  
  // Create View
  var f = CGRect(x:0,y:0,width:200,height:200)
  var view = UIView(frame:f)
  
  
  // Create Button
  var b = UIButton(frame: f)
  b.setTitle("Hello", forState: UIControlState.Normal)
  b.addTarget(s, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
  
  view.addSubview(b)
  
  view
  </code></pre>