ios - Swift: Performing a segue if PFObject = nil. -


currently have synced user , data on parse backend. want have user details page appear if users have not stated user details. there login page lead protected page (which show user details) , if there no details retrieved, page perform segue user details page.

var query = pfquery(classname:"usersettings")     var currentuser = pfuser.currentuser()     query.wherekey("user", equalto: currentuser!)     query.findobjectsinbackgroundwithblock {         (objects: [anyobject]?, error: nserror?) -> void in          if objects == nil {           self.performseguewithidentifier("filluserdetails", sender: self)         } 

however, segue not seem execute , remains on protected page rather directing new user user details page. appreciate , in advance.

the block executed on background thread. when update ui should on main thread. try wrapping performseguewithidentifier in block this:

var query = pfquery(classname:"usersettings") var currentuser = pfuser.currentuser() query.wherekey("user", equalto: currentuser!) query.findobjectsinbackgroundwithblock {     (objects: [anyobject]?, error: nserror?) -> void in      if objects == nil {         dispatch_async(dispatch_get_main_queue()) {             self.performseguewithidentifier("filluserdetails", sender: self)         }     } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -