I have two controllers, First- and SecondViewController. I want to share some methods of FirstViewController to use them in my SecondViewController.
This is how I create SecondViewController in FirstViewController:
sms = [[SecondViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:sms];
[self presentModalViewController:navController animated:YES];
I thought of passing the current instance of the FirstViewController to the SecondViewController which extends UIViewController. By default the initWithNibName method of SecondViewController is called.
How do I achieve this in objective-c?
Im not completely sure I understand the problem… as part of the issue has to do with how you are instantiating SecondViewController… posting that code could help.
but to answer your question as you have asked it…. “how to pass FirstViewController into SecondViewController”…
in your SecondViewController.h create your own init method
and in the .m file…
then.. and here is the key.. make sure you are calling the correct init method to instantiate SecondViewContoller
now.. having said that.. looking at your SO rating, I have a feeling you already knew this.. and the real question may be… why is the initWithNibName being called when you are not actually calling it explicitly?