我需要存储一些变量,如 ione 和 itwo 用于方法重复。变量值会增加,增加后,我想把增加的变量存入userdefaults。
import UIKit
class ViewController: UIViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
/* How can I load UserDefaults here to restore ione's value and
itwo's value and How to store them in UserDefaults ? */
let ionevalue = ione
println(ionevalue)
let itwovalue = itwo
println(itwovalue)
// Do any additional setup after loading the view, typically from a nib.
}
var ione = 0
var itwo = 0
ione++
itwo++
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}