Value of type UIViewController has no member topViewController after Xcode 7 update
16,769
You'd have to make it explicit, so that it knows you are trying to get the topViewController
from UINavigationController
in Swift 2:
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController
Author by
Michael Sebastian
Updated on June 10, 2022Comments
-
Michael Sebastian almost 2 years
After I updated to Xcode 7, I get this error "Value of type
UIViewController
has no member topViewController." Anyone else run into this? IstopViewController
no longer a part ofUIViewController
?override func viewDidLoad() { super.viewDidLoad() self.navigationItem.leftBarButtonItem = self.editButtonItem() let addButton = UIBarButtonItem(barButtonSystemItem: .Search, target: self, action: "addButtonPressed:") self.navigationItem.rightBarButtonItem = addButton if let split = self.splitViewController { let controllers = split.viewControllers self.detailViewController = controllers[controllers.count-1].topViewController as? ### Error heres DetailViewController } model = Model(delegate: self) // create the Model model.synchronize() // tell model to sync its data self.navigationController?.toolbarHidden = false; self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"Home", style:.Plain, target:nil, action:nil) }