【发布时间】:2021-06-22 23:00:23
【问题描述】:
我正在使用 TabBarcontroller 类型的应用程序,并且我正在使用表单的共享模型:
enum WorkoutState {
case Stopped
case Started
case Paused
}
class BaseTBController: UITabBarController {
var workoutState: WorkoutState? = .Stopped
}
目前一切正常,我可以使用
访问和更新不同选项卡中的变量let tabbar = tabBarController as! BaseTBController
if tabbar.workoutState = .Stop {
//do something
tabbar.workoutState = .Start
}
现在的情况是,我似乎需要将它放在我的代码中。例如:
startRun()
resumeRun()
pauseRun()
有没有更好的方法来代替放置
let tabbar = tabBarController as! BaseTBController
tabbar.workoutState = .Start
在 3 个函数中的每一个中?
【问题讨论】:
标签: ios swift uitabbarcontroller