I am working on a deep linking app where I need to assign the delegate of my deep link manager to my subclass of the tabbarcontroller
How can I return the root tabbarcontroller from inside the subclass of the tab bar controller?
Here is the app del function, where i call [TMDeeplinkManager searchForPodcast...] [self.mainTabController getMainTabBarController] i would like to change that to
[TMMainTabBarController mainTabBarController]
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
NSNumber *collectionId = [url host];
NSString *episodeTitle = [NSString stringWithFormat:@"%@", [url lastPathComponent]];
[TMDeeplinkManager searchForPodcastWithCollectionID:collectionId
title:episodeTitle
andDelegate:[self.mainTabController getMainTabBarController]];
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
This is the The subclass of the tabbarcontroller, How do I return the root view controller in the instancetype? without using the app del?
@interface TMMainTabBarController () <UINavigationControllerDelegate>
@property (strong, nonatomic) id selectedItem;
@end
@implementation TMMainTabBarController {
TMMainTabBarController *mainTabBarController;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)didSelectEpisode:(TMPodcastEpisode *)episode {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil] ;
TMAudioPlayerViewController *audioPlayerViewController = [storyboard instantiateViewControllerWithIdentifier:@"TMAudioPlayerViewController"];
audioPlayerViewController.episode = episode;
UINavigationController *mainNavController = self.viewControllers[0];
[mainNavController pushViewController:audioPlayerViewController animated:true];
}
-(void)setMainTabBarController:(TMMainTabBarController *)tabBarController {
mainTabBarController = tabBarController;
}
-(TMMainTabBarController *)getMainTabBarController {
return mainTabBarController;
}
+(instancetype)mainTabBarController {
return self.mainTabBarController;
}
@end