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
While pushing controller B from controller A..just specify
and then from B call the method A.The problem which you faced is due to non allocation and just declaratio of "viewControllerA " which you had created in B.
Make sure that the method loadData is specified in viewControllerB's header file.
After than, you can now call the method loadData.
viewControllerA is allocated in ViewControllerB before calling [viewControllerA loadData]?
You are missing
As long as somewhere in viewControllerB:
then:
will work.