El Tomato
El Tomato

Reputation: 6707

NSTableView Drawing Count

I have two tables (NSTableView) on a window. Well, the number is irrelevant. Anyway, the source of the first table (tableView1) is NSMutableArray with NSMutableDictionary. And I have the following code.

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
    if (aTableView == tableView1) {
        return [itemArray1 count];
    } else {
        ...
    }
}

- tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)TableColumn row:(NSInteger)rowIndex {
    // tableView1
    if (aTableView == tableView1) {
        NSString *foldername = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1a];
        NSString *count = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1c];
        if ([[TableColumn identifier] isEqualToString:@"folder"]) {
            return foldername;
        }

        if([[TableColumn identifier] isEqualTo:@"count"]){
            return count;
        }

        else {
            return @"";
        }

    // tableView2
    } else {
        ...
    }
}

I get what I want, and the second column shows the number of items (count). I wonder how I can possibly draw this number like the SidebarDemo example project? (Shown at the bottom...) This project utilizes - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item to show a static number (42). Can I show the number like that with NSTableView as well? I could just draw a circled number if it were an iOS application.

Thank you for your advice.

enter image description here

Upvotes: 0

Views: 114

Answers (1)

Amin Negm-Awad
Amin Negm-Awad

Reputation: 16650

tableView:viewForTableColumn:row: (NSTableViewDelegate) should work similar.

Upvotes: 1

Related Questions