我有一個功能deductCoins獲取功能價值的功能範圍以外的返回布爾值
func deductCoins() -> Bool {
if price > coins {
label.text = String("You dont have enough coins")
self.view.addSubview(label)
return false
}
if coins >= price {
coins = coins - price
UserDefaults.standard.set(coins, forKey: "Coins")
//this stuff has to do with the purchasing
BackBtn.removeFromSuperview()
PurchaseBtn.removeFromSuperview()
label.removeFromSuperview()
image.removeFromSuperview()
return true
}
return true
}
並且該功能用於扣除從UserDefaults值「硬幣」的硬幣(因此而得名),當用戶「購買內容「在我的遊戲中,我需要一種方法來測試函數deductCoins是否返回true或false,取決於用戶與項目的價格(如代碼中所述)相比較的硬幣數量,但是我需要測試if它在功能範圍外返回真或假
編輯
現在問題更加清楚了(P.S.當我寫下原件時,我感到很疲倦)
什麼*「偉大工程」 *又是什麼*「我需要或確定多個值瞭解鎖不是」 *是什麼意思? –
完全不清楚的問題.. – vaibhav
一個人可以得到你在問什麼 –