ios - Calling ViewController's method that pushes another ViewController from App Delegate -


before begin, have searched stackoverflow how this, , saw lot of related posts, none worked me , i'm not sure why.

so have loginviewcontroller, , in it, have method call's googlesignin:

- (void)googletap:(id)sender {     [[gidsignin sharedinstance] signin]; } 

now way googlesignin set up, result of sign in call handled inside appdelegate.m

- (void)signin:(gidsignin *)signin didsigninforuser:(gidgoogleuser *)user      witherror:(nserror *)error {     // perform operations on signed in user here.     if (!error) {         nsstring *userid = user.userid;                  // client-side use only!         nsstring *idtoken = user.authentication.idtoken; // safe send server         nsstring *name = user.profile.name;         nsstring *email = user.profile.email;          nslog(@"name: %@, user: %@, token: %@, email: %@",name, userid, idtoken, email);          // ...     } } 

inside appdelegate method, want call method loginviewcontroller:

-(void)onsuccessfullogin{     nslog(@"on successful login");     [self.navigationcontroller pushviewcontroller:[collectionviewcontroller new] animated:yes]; } 

i tried these answers: calling uiviewcontroller method app delegate

want call viewcontroller's method appdelegate

and nslog called, new viewcontroller never pushed...why , how can work?

if app delegate have no self.navigationcontroller. changed name of navigationcontroller uinavigationcontroller *navigationcontroller = [[uinavigationcontroller alloc] init] need set @property nav controller on delegate class. initialize nav controller

 uinavigationcontroller *navigationcontroller = [[uinavigationcontroller alloc] init]` self.navigationcontroller = navigationcontroller// need line.   //in method     [self.navigationcontroller pushviewcontroller:[collectionviewcontroller new] animated:yes]; 

Comments