Question

I'm working on an app that shows a list of data on an OutlineView. The controller receives notifications that tells it to change the image of the status NSImageCell of a row. The problem is that I couldn't managed to refresh the cell on the row of the OutlineView.

So far I've tried each of the options on the following code.

id dataCell = [self dataCellWithID:@"cellID" andRow:rowNumber];
if (dataCell && [dataCell isKindOfClass:[NSImageCell class]]) {
    //OPTION 1
    NSImageCell *statusIconCell = (NSImageCell *)dataCell;        
    [statusIconCell setImage:[NSImage imageNamed:[self syncIconNameForStatus: syncState]]];  

    //OPTION 2
    [dataCell setObjectValue:[NSImage imageNamed:[self syncIconNameForStatus: syncState]]];
    [dataCell reloadData];

    //OPTION 3
    NSIndexSet *rowIndex = [NSIndexSet indexSetWithIndex:listRow];
    NSIndexSet *columnIndex = [NSIndexSet indexSetWithIndex:[outlineView columnWithIdentifier:@"cellID"]];
    [outlineView reloadDataForRowIndexes:rowIndex columnIndexes:columnIndex];    
}

Any ideas?

Thanks in advance.

Mikywan.

Was it helpful?

Solution

Found the solution!

id dataCell = [self dataCellWithID:@"cellID" andRow:listRow];
if (dataCell && [dataCell isKindOfClass:[NSImageCell class]]) {
    NSImageCell *statusIconCell = (NSImageCell *)dataCell;        
    [statusIconCell setImage:[NSImage imageNamed:[self syncIconNameForStatus:syncState]]];  
    [[statusIconCell controlView] setNeedsDisplay:YES];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top