I have a little problem with a custom NSTableCellView
.
The problem: I have a Table View in a Nib with all stuff configured as well to load data from an array. For now, is OK. The problem is, while the app is preparing the views (using method (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
), the returned View is modified as I want (watched by a breakpoint before return), but the View that I can see, that everybody can see, is not modified.
I expect you could help me found the problem. I give you some stuff to help to understand my problem.
Some Images
Cell before get returned, as you can see, the View is modified as well.
Cell displayed in the Table View, in this case, the Custom View is not modified, it's look likes I didn't modified anything
Code
My custom NSTableCellView
, there's only a header...
@interface playlistQueueItemView : NSTableCellView
@property (weak) IBOutlet NSButton *button;
@property (strong) IBOutlet NSTextField *title;
@property (strong) IBOutlet NSTextField *artist;
- (void)setAllFromInitWithTitle:(NSString*)title artist:(NSString*)artist;
@end
Method for create the Views for the table:
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
playlistQueueItemView *cell = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
NSDictionary* song = [[PlaylistQueue getQueue] getSongWithPos:(int) row];
cell.artist.stringValue = song[@"artista"];
cell.title.stringValue = song[@"titulo"];
return cell;
}
One more thing, I followed a bit one of the Apple's sample projects, called TableViewPlayground.
Thanks :D
you have to override - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
and then return the view.
In - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
you can return a model object that has the value you want to populate.