I have a NSTableView where I wish to display a list of info.
Currently the viewForTableColumn method delegate never runs, but numberOfRowsInTableView does.
I have the NSTableViewDelegate and NSTableViewDataSource set in the ViewController head. And I set the tableview delegate and datasource to self. Does somebody know why it wouldn't run? I've added a screenshot and code below.
ViewController.h
@interface ViewController : NSViewController <NSTableViewDelegate, NSTableViewDataSource>
@property (strong) IBOutlet NSTableView *tableView;
@property (strong, nonatomic) NSMutableArray<App *> *installedApps;
@end
ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
_installedApps = [[NSMutableArray alloc] init];
_tableView.dataSource = self;
_tableView.delegate = self;
// Other stuff that populates the array
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return _installedApps.count;
}
-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSTableCellView *result = [tableView makeViewWithIdentifier:@"appCell" owner:self];
result.textField.stringValue = @"Hello world";
return result;
}
The view is in a container view, I have the 'appCell' identifier set to the Table Cell View.

self.installedAppsinstead of_installedAppsbecause the later might produce problems with KVO and subclassing. - clemens[self.tableView reloadData]when fill your array? - Kevinosaurio_tableViewnil? - Willeke