EDIT: Here is whole code example for Xcode 6.4
I have simple iOS application without storyboards. I set rootViewController
for UIWindow
in AppDelegate.swift
like this:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let tabBarController = TabBarController()
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
return true
}
TabBarController
class implementation is as follows:
class TabBarController: UITabBarController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Next line is called after 'viewDidLoad' method
println("init(nibName: bundle:)")
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
println("viewDidLoad")
}
}
When I run application the console output looks like this:
viewDidLoad
init(nibName: bundle:)
It means that lines after line super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
are called after viewDidLoad
method! This occurs only for classes that inherits from UITabBarController
. If you try this same example with UIViewController
descendant, everything is ok and viewDidLoad
is called after init method is executed.