title: How to make Singleton in Swift
body: <p>I want to use Singleton to show ads, but it doesn't work well.
  When I don't use Singleton and use only ViewController, it works well.(can through "vampLoadStart" and "vampDidReceive")</p>
  
  <p>How can I solve it?</p>
  
  <p><strong>Pattern1: when I use Singleton (can't load and show ad)</strong></p>
  
  <p>VAMPAdReward.swift</p>
  
  <pre><code>import Foundation
  import UIKit
  import VAMP
  
  class VAMPAdReward: NSObject,VAMPDelegate{
  
      static let sharedInstance = VAMPAdReward()
  
      var adReward:VAMP!
  
      override init() {
          super.init()
  
      }
  
      func loadAdReward(parentViewController: UIViewController) {
          adReward = VAMP()
          adReward.setPlacementId("26812") //test ID
          adReward.delegate = self
          adReward.setRootViewController(self)
  
      }
  
      func showAdReward(){
          if adReward.isReady() {
              print("show ad")
              adReward.show()
          }else{
              print("couldn't show ad")
          }
      }
  
      func vampLoadStart(_ placementId: String!, adnwName: String!) {
          print("start loading")
      }
  
      func vampDidReceive(_ placementId: String!, adnwName: String!) {
          print("finished loading")
      }
  }
  </code></pre>
  
  <p>ViewController</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      var adReward: VAMPAdReward!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          self.view.backgroundColor = UIColor.white
  
          VAMPAdReward.sharedInstance.loadAdReward(parentViewController: self)
  
      }
  
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
  
  
      super.touchesBegan(touches, with: event)
  
          //when touch screen, show Ad
          VAMPAdReward.sharedInstance.showAdReward()
  
      }
  }
  </code></pre>
  
  <p><strong>Pattern2: when I don't use Singleton (can load and show ad)</strong></p>
  
  <pre><code>import UIKit
  import VAMP
  
  class ViewController: UIViewController, VAMPDelegate {
  
      var ad: VAMP!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          self.view.backgroundColor = UIColor.white
  
          //load ad
          ad = VAMP()
          ad.setPlacementId("59755") //test ID
          ad.delegate = self
          ad.setRootViewController(self)
          ad.load()
  
      }
  
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          super.touchesBegan(touches, with: event)
  
          ad.show()
  
      }
  
      func vampLoadStart(_ placementId: String!, adnwName: String!) {
          print("start loading") //through
      }
  
      func vampDidReceive(_ placementId: String!, adnwName: String!) {
          print("finished loading") //through
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  </code></pre>