Question

i have a method in delegate.m file

-(void) switchToTabbarController  
{ 
  TabBarController *tabBarController = 
  [[TabBarController alloc] initWithNibName:@"TabBarController" bundle:nil];
  [self.window addSubview:tabBarController.view];
}

and i wanted to call this method from my LoginView Method. How to do it?

Was it helpful?

Solution

First I think you do not want to call it this way. I prefer not to call the UIApplication from a view and try to prevent it from a controller. Use a notification instead.

But the way you could do this is:

[(ApplicationDelegate *)[UIApplication sharedApplication].delegate switchToTabbarController]

OTHER TIPS

At first you have to import the header, and then create the object of your Delegate class, and then call the method. It will look like this:

#import "Delegate.h"

In place where you want to call it:

Delegate* del=[[Delegate alloc] init];
[del switchToTabbarController];

And after you are done, I would strongly suggest reading Apple's Objective-C Programming Guide: Link.

EDIT: if this is your AppDelegate, go with Mats' solution.

include header file -
#include

create instance of this class delegate *d=[[delegate alloc] init]; [d switchToTabbarController];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top