On May 1, 2014, at 17:25 , Varun Chandramohan <varun.chandramo...@wontok.com> 
wrote:

> Yes I have implemented tableView:isGroupRow.
> - (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
>     DesktopEntity *entity = _tableContents[row];
>     if ([entity isKindOfClass:[DesktopFolderEntity class]]) {
>         return YES;
>     }
>     return NO;
> }
> 
> What is wrong with this?

Nothing at all! Rows corresponding to a ‘DesktopFolderEntity’ are group rows, 
and all the others are not.

> Also I implemented 
> - (NSView *)tableView:(NSTableView *)tableView 
> viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
>     DesktopEntity *entity = _tableContents[row];
>     if ([entity isKindOfClass:[DesktopFolderEntity class]]) {
>         NSTableCellView *groupCell = [tableView 
> makeViewWithIdentifier:@"GroupCell" owner:self];
>         [groupCell.textField setStringValue:entity.name];
>         return groupCell;
>     }
>     return nil;
> }
> 
> Are you saying I should not return nil here?

Well, you are returning nil for rows that aren’t ‘DesktopFolderEntity’, which 
doesn’t seem a good idea, but that isn’t the issue you asked about.

In this code, you should return a view with identifier “GroupCell” — as you 
have done — for rows that are ‘DesktopFolderEntity’. Since these are indeed 
group rows, this correctly gives them the group-row appearance (the one with 
the gray background).

That is, your table view is showing exactly what you asked it to show.

Your ‘tableView:viewForTableColumn:’ method is, however, missing some code. You 
need to return a view for non-group rows (that would probably be a view with 
identifier ‘DataCell’, if you have the default setup in IB), and you need to 
test tableColumn (and possibly tableColumn.identifier). (‘tableColumn == nil’ 
means that you’re being asked for a group-row view. Otherwise you’re being 
asked for a per-column view.)
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to