I have a ViewControllerA and a ViewControllerB. I want calling a method of ViewControllerA from ViewControllerB.
In ViewControllerA is present a method:
-(NSMutableArray*) loadData;
In ViewControllerB.h:
#import "ViewControllerA.h"
.......
@property (nonatomic, strong) ViewControllerA * viewControllerA;
@property (nonatomic, strong) NSMutableArray * mutableArray;
In ViewControllerB.m:
self.mutableArray =[viewControllerA loadData];
but the method is not calling. Why? Thanks in advance
You are missing
self.
As long as somewhere in viewControllerB:
self.viewControllerA = [[viewControllerA alloc]init]; //or some other initialization occurs...
then:
self.mutableArray =[self.viewControllerA loadData];
will work.
Make sure that the method loadData is specified in viewControllerB's header file.
- (void)loadData;
After than, you can now call the method loadData.
[viewControllerA loadData];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With