I have an app where there are 2 roles, "admin" and "employee". At sign up I have the segue set up into the sign up button and it automatically performs the right segue to the employee or admin view controllers. But after the user is created and logged out and try to log back in how can I set up a conditional if else statement that queries the role of the current user and performs the correct segue accordingly. thanks in advance. here is the code i have on the initial view controller/Login Screen.
override func viewDidAppear(animated: Bool) {
//need to query current users role...and then if else, and segue to either Admin Home or Employee Home
var roleQueryClass = PFQuery(className: "_Role")
var roleQuery = PFRole.query()
roleQuery?.whereKey("name", equalTo: "Admin")
roleQuery?.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
if let role = objects {
for object in role {
if let role = object as? PFRole {
if PFRole() == PFUser.currentUser() {
self.performSegueWithIdentifier("toHomeFromSignUp", sender: self)
} else {
self.performSegueWithIdentifier("toEmployeeHome", sender: self)
At the time of signup save the role in NSUserDefaults, and at the time of login , check the value in NSUserDefaults , and segue accordingly.