当你点击按钮时(Int)0。有人告诉我如何解决这个错误?我尝试没有连接到服务器,这种方法工作。我需要帮助帮助。这个错误的原因是什么?做过课程appcoda像Instagramm。
import UIKit
class CustomSoccerHeaderView: UITableViewHeaderFooterView {
var saveBravo: Soccer?
@IBOutlet weak var bravoBtn: UIButton! {
didSet {
bravoBtn.layer.cornerRadius = bravoBtn.frame.size.width/2
bravoBtn.layer.masksToBounds = true
}
}
@IBOutlet weak var countBravo: UILabel!
@IBAction func saveClick(_ sender: UIButton) {
if (saveBravo != nil) {
if var clickBravissimo: Int = saveBravo!.object(forKey: "bravissimo") as? Int {
clickBravissimo += 1
saveBravo!.setObject(clickBravissimo, forKey: "bravissimo")
saveBravo!.saveInBackground()
}
}
}
@IBOutlet weak var nameHeader: UILabel!
@IBOutlet weak var imageHeader: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}