Pass a class as a parameter?
Posted
by JuBu1324
on Stack Overflow
See other posts from Stack Overflow
or by JuBu1324
Published on 2009-06-23T04:20:47Z
Indexed on
2010/05/24
5:51 UTC
Read the original article
Hit count: 203
I have been lead to believe that it is possible to pass a class as a method parameter, but I'm having trouble implementing the concept. Right now I have something like:
- (id)navControllerFromView:(Class *)viewControllerClass
title:(NSString *)title
imageName:(NSString *)imageName
{
viewControllerClass *viewController = [[viewControllerClass alloc] init];
UINavigationController *thisNavController =
[[UINavigationController alloc] initWithRootViewController: viewController];
thisNavController.tabBarItem = [[UITabBarItem alloc]
initWithTitle: title
image: [UIImage imageNamed: imageName]
tag: 3];
return thisNavController;
}
and I call it like this:
rootNavController = [ self navControllerFromView:RootViewController
title:@"Contact"
imageName:@"my_info.png"
];
What's wrong with this picture?
© Stack Overflow or respective owner