0

I am trying to call an API after GoogleSignindelegate which will check for existing user if not it will open a form to signup. Here what i did "

I defined a push segue from current controller to destination controller and named as login2 after that if user click google signin button we will check for its existence in our database:

func getGoogleData(let  uId:AnyObject, let emailId:AnyObject, let name:AnyObject){
        accountType = "GOOGLE"
        accountId = uId as! String
        self.emailId = emailId as! String
        self.name = name as! String
        print(accountId)
        print(accountType)
        self.appData.setValue(self.accountId, forKey: "uId")
        self.appData.setValue(self.accountType, forKey: "uAccountType")
        self.appData.synchronize()
        self.checkAlreadyExist()
    }

after async we call uiRefresh method to go to destination segue:

func do_ui_refresh(){
        dispatch_async(dispatch_get_main_queue(), {
            if(self.appData.stringForKey("userId") == nil){
                self.performSegueWithIdentifier("login2", sender: self)
            }
            else{
                self.performSegueWithIdentifier("loginAlready", sender: self)
            }
            return
        })
    }

But every time when i run app it shows no Receiver () has no segue with identifier 'login2'

but i defined a segue i can clearly see it in inspector.

Segue Image

Any help is appreciated.

gauravmehra
  • 149
  • 2
  • 11
  • could you please add a screenshot with the segue definition? – fiks Jul 20 '16 at 12:50
  • What type is `self`? Also did you load your current view controller with storyboard? – fiks Jul 20 '16 at 13:08
  • yes i did load my controller with storyboard and self is call this storyboard method. – gauravmehra Jul 20 '16 at 13:12
  • Did you also try to clean everything and reinstall the app? Some people say it might help: http://stackoverflow.com/questions/11874200/nsinvalidargumentexception-receiver-has-no-segue-with-identifier I can't help you more at the moment. If you want, you can post the full code of the view controller together with the way how you initialise it, it might help to understand the problem better. – fiks Jul 20 '16 at 13:38
  • I did all those things doing R&D for hours but it didn't work, I dont understand what's the problem . – gauravmehra Jul 20 '16 at 13:54

1 Answers1

0

Ok after doing some R&D I figured out there is something wrong with implementation. We can't do perform segue operation in AppDelegate as No view has been loaded in it so If we want to open a view from AppDelegate we have to define view controller id and then we have to use following code:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
                    let rootVC = storyboard.instantiateViewControllerWithIdentifier("ViewControllerID") as! UIViewController
                    self.window!.rootViewController = rootVC

also we can implement this thing in Opening which through which we can perform segue operation.

gauravmehra
  • 149
  • 2
  • 11