Reputation: 59
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?
Upvotes: 0
Views: 90
Reputation: 4092
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.
Upvotes: 2
Reputation: 655
include header file -
#include
create instance of this class delegate *d=[[delegate alloc] init]; [d switchToTabbarController];
Upvotes: 1
Reputation: 5098
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]
Upvotes: 1