简体   繁体   English

不能在IBAction外部使用变量

[英]Can't use variable inside of an IBAction outside of it

Can't use variable inside of an IBAction outside of it 不能在IBAction外部使用变量

Code: 码:

if timerRunning==true && timerCount==actualWorkoutLength {
    timer.invalidate()
    timerRunning = false
    timerCount=0
    timerLabel.text="0 secs"
    intervalAlert()
}

Screenshot: 屏幕截图: http://i.gyazo.com/86e0143893413c2dd50d59ecba7cf460.png

I look your screenshot and actualWorkoutLength is a local variable of another method. 我看了看您的屏幕截图, actualWorkoutLength是另一种方法的局部变量。

BTW: In startButton(sender: UIButton) you will never see it. 顺便说一句:在startButton(sender: UIButton)您将永远看不到它。

If you want to see it. 如果您想看到它。 Declare actualWorkoutLength as global variable actualWorkoutLength声明为global variable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM