Reputation: 151
Between 2 user types, if either of the users clicks on 'Item 1' of a tab bar controller, is it possible to direct to different view controllers depending on the value of a boolean property for that user?
Upvotes: 1
Views: 63
Reputation: 5643
Sure, i think your user type coming from back end according to your id. So you can do something like below.
struct User {
salesPerson = false
// other properties
}
let user = User()
if user.salesPerson { // that means salesPerson is true
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "SalesPersonViewController") as? SalesPersonViewController
self.navigationController?.pushViewController(vc!, animated: true)
} else { // that means false so you can push other vc
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main)
.instantiateViewController(withIdentifier: "AdminViewController") as? AdminViewController
self.navigationController?.pushViewController(vc!, animated: true)
}
Upvotes: 1