Reputation: 323
i have a MainViewController and multiple SubViews in it. i have a NSMutableArray in my MainViewController but i need it inside my SubView so how can i access that mutablearray from my subview when it is present as a child of MainViewController?
Upvotes: 0
Views: 36
Reputation: 1790
Simply create an array property in your subview class and pass the array from your main viewcontroller to your subview class when you initialise your subview.
Code in your main viewcontroller:
YourSubviewClass *subView = [[YourSubview alloc] init];
subView.array = self.yourMainViewControllArray
Code in your subview class header file:
@interface YourSubviewClass : UIView
@property (nonatomic) NSMutableArray *array;
Hope this helps, good luck.
Upvotes: 1