After better understanding what you're trying to do I think I would use delegates. Although there are other ways to do this I think that delegates are flexible and if you haven't used them yet then this is a good time to learn about them.
We define the delegate methods that a class needs to implement if it wishes to adopt our protocol:
MyScrollView.h
@protocol MyScrollViewDelegate <NSObject>
-(void)reloadTableData;
@end
@interface MyScrollView : UIScrollView
@property (nonatomic,weak) id<MyScrollViewDelegate> delegate;
@end
Then in the implementation we do the following:
MyScrollView.m
// Set the button's target
[button addTarget:self action:@selector(reloadData) forControlEvents:UIControlEventTouchUpInside];
// Here we check if our delegate responds to the reloadTableData selector and if so we call it
-(void)reloadData
{
if ([self.delegate respondsToSelector:@selector(reloadTableData)])
{
[self.delegate reloadTableData];
}
}
In the implementation of MyViewController we add the MyScrollViewDelegate
and implement the reloadTableData
method:
MyViewController.m
@interface MyViewController () <MyScrollViewDelegate>
@property (strong, nonatomic) MyScrollView* scrollView;
@property (strong, nonatomic) IBOutlet UITableView *table;
@end
// Set the delegate after you've created scrollView
self.scrollView.delegate = self;
// Once the delegate is called we simply reload the table data
-(void)reloadTableData
{
[self.table reloadData]
}