NSTableView problem in xcode 6

Discussion in 'Mac Programming' started by larswik, Jan 26, 2015.

  1. larswik macrumors 68000

    Sep 8, 2006
    It looks like Apple changed something and I can't figure it out. I looked at some old osx apps that work but a new project I am working on isn't.

    Simple set up so far, TableView with 2 columns and when I press an NSButton it should fill the tableview with "102" in the ID column and "Pet Lounge..."

    Included 4 photos to better illustrate what I see. The screen shot at 4:03 shows that I labeled the the text cells and also the identifier to the right under the identity inspector.

    2 of the photos show the identifier is "idNum" and the other show the Client object has a value for idNum that is "102" which should be returned.

    The last image is of the app after I pressed the button 3 times, it just says "Text View Cell" 3 times. I'm pretty sure I am missing something simple here and something has changed with the NSTableViews from previous versions. I did search for tutorials but everything I followed was old, nothing from xcode 6. Anyone have an idea of the step that I am missing?

    #import "TableViewController.h"
    @implementation TableViewController
        self = [super init];
        if (self) {
            list = [[NSMutableArray alloc]init];
        return self;
        tableView.delegate = self;
        tableView.dataSource = self;
        [list addObject:[[Client alloc]init]];
        [tableView reloadData];
    -(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
        return [list count];
    -(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
        Client *c = [list objectAtIndex:row];
        NSString *identifier = [tableColumn identifier];
        return [c valueForKey:identifier];

    Attached Files:

  2. Ritsuka, Jan 27, 2015
    Last edited by a moderator: Jan 27, 2015

    Ritsuka macrumors 6502a

    Sep 3, 2006
    Lion introduced view-based tableviews that works in a different way. If your tableview is view-based you to implement the

    - (NSView *)tableView:(NSTableView *)tableView
       viewForTableColumn:(NSTableColumn *)tableColumn
    data source method.

    You can switch between cell-based and view-based tableviews in the xib. If you don't need 10.6 compatibility you should use the view-based one.
  3. larswik thread starter macrumors 68000

    Sep 8, 2006
    Thanks for the reply, I will check it out today. I do need 10.6 since that is the os that it will need to run on at work.

Share This Page