I have two view controllers (viewControllerA
and viewControllerB
) with their own views. When the user touches a button in the view of viewControllerA
, I am able to load the view of the viewControllerB
.
However, I don't know how to invoke a method in viewControllerB
's class!
Without much info to go on I'll assume that both A & B are of the same class (though they wouldn't have to be). You could always declare a property that would then point from one to the other:
MyViewController.h:
@interface MyViewController : UIViewController {
MyViewController *altViewController;
}
@property (nonatomic, retain) MyViewController *altViewController
@end
Just be sure that once instantiated you populate that property with a pointer to the other VC. Then you can easily call a method on the other view controller simply by:
[altViewController doMethod];