[英]Cannot assign to property 'tabBarController' is a get-only property
I have declared a global variable:我已经声明了一个全局变量:
var tabBarController: UITabBarController?
Now when I try to assign to this global variable inside my UITabBarController
class:现在,当我尝试在我的UITabBarController
类中分配给这个全局变量时:
override func viewDidLoad() {
tabBarController = self
}
I receive this error:我收到此错误:
Cannot assign to property 'tabBarController' is a get-only property无法分配给属性“tabBarController”是一个只能获取的属性
Why am I getting this?为什么我得到这个?
Your own property collides with an already existing property of the same name that every UIViewController
has:您自己的属性与每个UIViewController
具有的同名的现有属性发生冲突:
tabBarController - The nearest ancestor in the view controller hierarchy that is a tab bar controller. tabBarController - 视图控制器层次结构中最近的祖先是选项卡栏控制器。
var tabBarController: UITabBarController? { get }
As you can clearly see that property is get
-only.正如您可以清楚地看到该属性是get
-only。
If you choose a different name for that property you will be fine.如果您为该属性选择不同的名称,您会没事的。 Or you configure all the connections in the interface builder beforehand.或者您事先在界面构建器中配置所有连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.