私は変数well ... 2変数を保存するのに助けが必要です。 は、ここに私のViewController file.IがNSUser試みたですが、人々はそれだけ設定するには設定のユーザデータetc.Anyのヘルプのために使用することができてうれしい:) おかげ変数を素早く保存する
import UIKit
var wreath = 0
var box = 0
class ViewController: UIViewController {
@IBOutlet weak var YouHaveB: UILabel!
@IBOutlet weak var YouHaveW: UILabel!
@IBAction func Wreaths(sender: AnyObject) {
wreath += 1
YouHaveW.text = "You Have \(wreath) Wreaths"
}
@IBAction func Boxes(sender: AnyObject) {
box += 1
YouHaveB.text = "You Have \(box) Boxes"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
これらをNSUserDefaultsに追加する際に問題はありません。 – Gruntcakes
私は試みましたが動作しませんでした:( –
投稿を更新しても動作しないコードを表示します – Gruntcakes