I must be overthinking this simple parent and subclass communication in Objective-C.
I am creating and filling an NSMutableArray in the parent View Controller, then in the subclass View Controller I want to access the objects in that array. Xcode is not throwing any errors, but in the subclass it is not finding any objects in the array. What am I doing wrong?
Parent.h:
@interface ParentViewController : UIViewController
@property (strong, nonatomic) NSMutableArray *myArray;
@end
Parent.m:
[self.myArray addObject:myString]; //add objects to array in a method
Subclass.h:
#import "ParentViewController.h"
@interface SubclassViewController : ParentViewController
@end
Subclass.m:
#import "SubclassController.h"
@implementation SubclassViewController
- (void)myMethod {
NSLog(@"%d in parent array", [super.myArray count]); //always returns 0
}
@end
myArrayis never initialised.