Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get NSTableView to display data
    primarykey
    data
    text
    <p>I see there are a lot of questions about this, but nothing helped me to get this work. I have a nib with a NSTableView with three columns (with the right identifiers set) and a class named ShortcutsTableController. In the nib I have a NSObject with class value ShortcutsTableController. I also connected the NSTableView to my controller as I usually do.</p> <p>This is header <code>ShortcutsTableController.h</code>.</p> <pre><code>#import &lt;Cocoa/Cocoa.h&gt; @interface ShortcutsTableController : NSObject &lt;NSTableViewDataSource&gt; { IBOutlet NSTableView *shortcutsTable; NSMutableArray *shortcutsList; } - (int) numberOfRowsInTableView: (NSTableView*) tableView; - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row; @property (assign) IBOutlet NSTableView *shortcutsTable; - (void)setUpTable; @end </code></pre> <p>And this is the implementation file <code>ShortcutsTableController.m</code>.</p> <pre><code>#import "ShortcutsTableController.h" @implementation ShortcutsTableController @synthesize shortcutsTable; - (void)setUpTable { shortcutsList = [[NSMutableArray alloc] init]; NSDictionary *dict1 = [NSDictionary dictionaryWithObjectsAndKeys: @"blabla", @"nameColumn", @"Bla bla bla", @"shortcutColumn", @"Ribla", @"actionColumn", nil]; [shortcutsList addObject:dict1]; [shortcutsTable setDataSource:self]; [shortcutsTable reloadData]; } -(int) numberOfRowsInTableView: (NSTableView *) tableView { return [shortcutsList count]; } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { if (row != -1) return [[shortcutsList objectAtIndex:row] objectForKey:[tableColumn identifier]]; return nil; } @end </code></pre> <p>But when i try to build nothing appears in the NSTableView. No errors, no warnings. Note that I call setUpTable from within the Delegate Class Method <code>awakeFromNib</code>.</p> <p>Is there something I am doing wrong? Thank you for you help.</p> <p>—Albé</p> <p>UPDATE. Added lines <code>@property (assign) IBOutlet NSTableView *shortcutsTable;</code> in header and <code>@synthesize shortcutsTable;</code> in implementation. Nothing changes. :(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload