title: How to remove iAd from application, using SpriteKit and Xcode 7 beta in Swift 2?
body: <p>I made a game that have iAd interstitial using Xcode 7 beta and SpriteKit in Swift 2, I tried to use a function to remove them but It's not working. I'm using two different files, <strong>GameScene.swift</strong> and <strong>GameViewController.swift</strong>.</p>
  
  <p>Code that I used in file, <strong>GameScene.swift</strong>:</p>
  
  <pre><code>func gameOver() {
      isGameOver = true
      print("Game Over")
  
      loadAd()
  }
  //iAd
  func close(sender: UIButton) {
      closeButton.removeFromSuperview()
      interAdView.removeFromSuperview()
  }
  
  
  func loadAd() {
      print("load ad")
      interAd = ADInterstitialAd()
      interAd.delegate = self
  
      closeButton.frame = CGRectMake(15, 15, 22, 22)
      closeButton.layer.cornerRadius = 11
      closeButton.setTitle("x", forState: .Normal)
      closeButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
      closeButton.backgroundColor = UIColor.whiteColor()
      closeButton.layer.borderColor = UIColor.blackColor().CGColor
      closeButton.layer.borderWidth = 1
      closeButton.addTarget(self, action: "close:", forControlEvents: UIControlEvents.TouchDown)
  
  }
  
  func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) {
      print("ad did load")
  
      interAdView = UIView()
      interAdView.frame = self.view!.bounds
      view!.addSubview(interAdView)
  
      interAd.presentInView(interAdView)
      UIViewController.prepareInterstitialAds()
  
      interAdView.addSubview(closeButton)
  }
  
  func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {
  
  }
  
  func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) {
     print("failed to receive")
      print(error.localizedDescription)
  
      closeButton.removeFromSuperview()
      interAdView.removeFromSuperview()
  
  }
  </code></pre>
  
  <p>In <strong>GameViewController.swift</strong> is In-App Purchase to remove ads (to buy Pro Version):</p>
  
  <pre><code>@IBAction func removeAds(sender: UIButton) {
      print("Remove Ads Button pressed")
      for product in list {
          let prodID = product.productIdentifier
          if(prodID == "Squares.RemoveAds") {
              p = product
              buyProduct()
              break;
          }
      }
      SKPaymentQueue.defaultQueue().addTransactionObserver(self)
      SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
  }
  
  
  func removeAds() {
  
  }
  
  override func prefersStatusBarHidden() -&gt; Bool {
      return true
  }
  
  //Remove Ads Payment
  var list = [SKProduct]()
  var p = SKProduct()
  
  
  //Squares.regular.removeAds
  //Squares.6Plus.removeAds
  
  
  func buyProduct() {
      print("Buy" + p.productIdentifier)
      let pay = SKPayment(product: p)
      SKPaymentQueue.defaultQueue().addTransactionObserver(self)
      SKPaymentQueue.defaultQueue().addPayment(pay as SKPayment)
  }
  
  func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
      print("Product Request")
      let myProduct = response.products
  
      for product in myProduct {
          print("Product Added")
          print(product.productIdentifier)
          print(product.localizedTitle)
          print(product.localizedDescription)
          print(product.price)
  
          list.append(product as SKProduct)
      }
      removeAdsButton.enabled = true
      removeAdsIPhone6Plus.enabled = true
  }
  
  func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue) {
      print("Transactions Restored")
  
      var purchasedItemIDS = []
      for transaction in queue.transactions {
          let t: SKPaymentTransaction = transaction as SKPaymentTransaction
  
          let prodID = t.payment.productIdentifier as String
  
          switch prodID {
          case "Squares.RemoveAds":
              print("Remove Ads")
              removeAds()
          case "Squares.RemoveAds":
              print("Remove Ads for iPhone 6 Plus")
              removeAds()
          default:
              print("IAP not setup")
          }
  
      }
  }
  
  func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
      print("Add Payment")
  
      for transaction:AnyObject in transactions {
          let trans = transaction as! SKPaymentTransaction
          print(trans.error)
  
          switch trans.transactionState {
  
          case .Purchased:
              print("Buy, Ok unlock Squares here")
              print(p.productIdentifier)
  
              let prodID = p.productIdentifier as String
              switch prodID {
                  case "Squares.RemoveAds":
                  print("Remove Ads")
                  removeAds()
                  case "Squares.RemoveAds":
                  print("Remove Ads for iPhone 6 Plus")
                  removeAds()
              default:
                  print("IAP not Setup")
              }
  
              queue.finishTransaction(trans)
              break;
          case .Failed:
              print("Buy Error")
              queue.finishTransaction(trans)
              break;
          default:
              print("Default")
              break;
  
          }
      }
  }
  
  func finishTransaction(trans:SKPaymentTransaction){
      print("Finish Transaction")
  }
  
  func paymentQueue(queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {
      print("Remove Transaction")
  }
  </code></pre>
  
  <p>If You read the code in file <strong>GameViewController.swift</strong> function <code>removeAds()</code> is empty and is called in some codes in same file, so it will remove ads forever,and what I need to do is to put a code in function <code>removeAds()</code> that will remove ads permanently, the problem is what I don't know how to call it and in which way to remove them, because functions are in different files, I tried many ways but doesn't work. 
  Can You show me please with more details how to do that ?</p>