Within my storyboard I have a simple view controller that contains a UITableView within it.
SceneFormVC.m
@property (nonatomic, strong) IBOutlet SceneFormTV *sceneFormTable;
In the process of improving my MVC and making a 'lighter' VC, I subclassed the UITableView for better seperation of concerns and code reuse.
SceneFormTV.h
@interface SceneFormTV : UITableView <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
SceneFormTV.m
@implementation SceneFormTV
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
self.dataSource = self;
self.delegate = self;
}
return self;
}
The issue here is when I try to set the dataSource/delegate = self
inside my subclass during initWithCoder
(as called by the storyboard setup), then it has no effect in causing the rest of the UITableView methods to be called (eg. (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath)
But if I set the dataSource/delegate
pointers within the main VC (SceneFormVC.m), then the UITableView works as expected.
@implementation SceneFormVC
- (void)viewDidLoad
{
[super viewDidLoad];
self.sceneFormTable.dataSource = self.sceneFormTable;
self.sceneFormTable.delegate = self.sceneFormTable;
I don't quite understand why my SceneFormTV
subclass fails to operate when it sets up itself with the exact same dataSource/delegate
pointers internally?