Hi! I've got a PHP background, but I'm beginning to learn Objective-C, so that I can develop apps for the iPhone. So far things are going pretty well, but I've got a question that I haven't been able to find and answer to yet after googling and mining a number of different forums.
My app has to create a number of views, each with it's own uinque title bar. In order to do this, my code looks something like this for each view:
xViewController = [ [ XViewController alloc ] init ];
xNavController = [ [ UINavigationController alloc ]
initWithRootViewController: xViewController
];
xNavController.tabBarItem = [ [ UITabBarItem alloc ]
initWithTitle: @"My Info"
image: [ UIImage imageNamed: @"my_info.png" ]
tag: 3
];
This works, but what I'd like to do is to create a method that will return a nav controller when sent a string as a message, so I don't have to do all this for each view. The issue I am having is that the first line needs to allocate an object based on a class name passed to it as a string (i.e. XViewController needs to be taken from a string passed to the method), but I don't know how to treat a string as a class name. I know it's possible, because the UIApplicationMain() can use a string to call the app delegate class. How can I do it?
I'm sorry if any of this doesn't make sense, I'm still in the early stages of learning a new language!