swift - How to segue based on the PFRole of the current user -


i have app there 2 roles, "admin" , "employee". @ sign have segue set sign button , automatically performs right segue employee or admin view controllers. after user created , logged out , try log in how can set conditional if else statement queries role of current user , performs correct segue accordingly. in advance. here code have on initial view controller/login screen.

override func viewdidappear(animated: bool) {  //need query current users role...and if else, , segue 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 {      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 time of signup save role in nsuserdefaults, , @ time of login , check value in nsuserdefaults , , segue accordingly.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -