MTA MTA - 1 year ago 127
Objective-C Question

NSTableView cell text not changed

I am using

in my osx application:

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
if (tableView == self.categoryTable) {
return [[[AppAPI shared] categoryArr] count];
return 0;

- (nullable id)tableView:(NSTableView *)tableView objectValueForTableColumn:(nullable NSTableColumn *)tableColumn row:(NSInteger)row {
if (tableView == self.categoryTable) {
NSTableCellView *cellView = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];

CategoryItem * cat = [[AppAPI shared] categoryArr][row];

cellView.textField.stringValue =;

return cellView;

return nil;

I use this code to insert data to the table, but all i get is rows with this text : enter image description here

is not nil

Any idea why it happens?

Answer Source

You are using the wrong delegate / data source methods

objectValueForTableColumn:row is supposed to return the object for the row

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    return [[AppAPI shared] categoryArr][row];

viewForTableColumn:row: returns the view.

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    return [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];

PS: How many table views are in your design that you have to check for the right one?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download