override func viewDidLoad() {
super.viewDidLoad()
SuccessMark.maximumValue = 100
SuccessMark.value = successMark
}
override func viewDidDisappear(_ animated: Bool) {
let successMark = SuccessMark.value
}
答案 0 :(得分:0)
在任何函数之外的viewcontroller类中声明变量。这样整个viewcontroller类就能够读取和写入变量。
Class ViewController: UIViewController {
var successMark: YourCustomType! // either initialise it empty or use optionals as needed, YourCustomType! or YourCustomType?
override func viewDidLoad() {
super.viewDidLoad()
SuccessMark.maximumValue = 100
SuccessMark.value = successMark
}
override func viewDidDisappear(_ animated: Bool) {
successMark = SuccessMark.value
}
}