Reputation: 16416
I have declared a global variable:
var tabBarController: UITabBarController?
Now when I try to assign to this global variable inside my UITabBarController
class:
override func viewDidLoad() {
tabBarController = self
}
I receive this error:
Cannot assign to property 'tabBarController' is a get-only property
Why am I getting this?
Upvotes: 2
Views: 1420
Reputation: 57114
Your own property collides with an already existing property of the same name that every UIViewController
has:
tabBarController - The nearest ancestor in the view controller hierarchy that is a tab bar controller.
var tabBarController: UITabBarController? { get }
As you can clearly see that property is 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.
Upvotes: 2