NSImageCell change image problem

1.5k views Asked by At

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.

1

There are 1 answers

0
mikywan On BEST ANSWER

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];
}