Reputation: 70416
I have a custom init method for my SecondViewController : UIViewController
-(id) initWithFirstViewController:(FirstViewController *)theFirstViewController
{
self = [super init];
fvc = theFirstViewController;
return self;
}
So in my FirstViewController
I call this init method with an instance of the FirstViewController
as a parameter. Somewhere else in the SecondViewController
I use this passed intance:
[fvc setSomething];
The method is executed but I get a warning:
Method
-setSomething
not found (return type defaults toid
)
How to fix this?
Upvotes: 0
Views: 3803
Reputation: 92335
In this case, it's a matter of #import
ing the corresponding .h
file so the compiler knows about the method.
Additionally, you should retain theFirstViewController
as chances are that it gets released and a different object is created at exactly the same memory location (to which fvc
is still pointing). So you should do fvc = [theFirstViewController retain];
as you are "holding on to" the first view controller (you want to make use of it later on). Don't forget to release it in your dealloc
.
Upvotes: 3