So the question is like this:
I subclass 2 classes, which is UIView(name: Menu) and UIViewController(name: MainController). In Menu, i used xib file to create it layout. In MainController, i added Menu as subview like this and comform to protocol in Menu.
SliderMenu *sliderMenu = [[[NSBundle mainBundle] loadNibNamed:@"SliderMenu" owner:self options:nil] objectAtIndex:0];
sliderMenu.datasource = self;
sliderMenu.delegate = self;
[self.view addSubview:sliderMenu];
The layout works perfectly, there is no problem with it.
The problem is with DataSource. i call a datasource method in awakeFromNib
- (void)awakeFromNib {
// Alloc data
self.data = [[NSArray alloc] initWithArray:[self.datasource arrayOfData]];
}
and that never even get called. After trying and trying i found out that, sliderMenu.datasource = self;
is run after awakeFromNib. Thats is why the datasource method in MainController is never get called.
Question: How can i solve this problem?