I currently have a chiclet on a viewcontroller that when pressed its supposed to navigate to a viewcontroller that is located in the tab bar. The viewcontrollers in the tab bar are all custom view controllers. When the chiclet is tapped I want to to navigate to a specific tab bar's selectedIndex but change a property value on that specific tab bar's viewcontroller before the switch. For example:
case .currentMap:
let selectedIndex = mainTabController.selectedIndex
let selectedController = mainTabController.selectedViewController
if selectedController == MapViewController {// error Binary operator '==' cannot be applied to operands of type 'UIViewController?' and 'MapViewController.Type'
selectedController.isMapSelected = true// Value of type 'UIViewController?' has no member 'isMapSelected'
}
Any idea on how to do this property so that after clicking on chiclet the tab bar still appears at the bottom?
if let selectedController = mainTabController.selectedViewController as? MapViewController {
selectedController.isMapSelected = true
}
This will grab the selected view controller, attempt to cast it as MapViewController
, and if succesful then you can access the property.