在 Swift 中每 3 场比赛播放插页式广告

Play interstitial ad every 3rd game in Swift

我在这里找到了 Objective-C 的可接受答案:

但是,我正在尝试在 Swift 中做同样的事情。我正在寻找如何编写静态变量。

这是 Objective-C 代码:

static int count = 0;

-(void) GameOver {
   if(count != 0 && count % 3 == 0)
     [HZInterstitialAd show];

   count++;
}
private var count = 0

func GameOver {
  if (count != 0 && count % 3 == 0) {
    HZInterstitialAd.show()
  }
  count++
}