Reputation: 3958
I need to pass some parameters from the appDelegate to a viewController before loading it.
This is the code i'm trying to use (in the appDelegate.swift):
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let secondView = storyboard.instantiateViewControllerWithIdentifier("tab") as UITabBarController
secondView.variable = "xxxx"
self.window?.rootViewController = secondView;
but the compiler shows the following error:
UITabBarController does not have a member named 'variable'
Even thought, in the TabBarController class (TabBarController.swift) i have the following:
import UIKit
class TabBarController: UITabBarController {
var variable:String!
...etc
What's the error? Please give a clear explanation as i'm a beginner in Swift. Thank you very much!!
Upvotes: 1
Views: 1256
Reputation: 21
Your second line should be
let secondView = storyboard.instantiateViewControllerWithIdentifier("tab") as TabBarController
Upvotes: 1
Reputation: 7850
You have TabBarController
, but you instantiate as UITabBarController
.
Upvotes: 2