Note that there are some explanatory texts on larger screens.

plurals
  1. POAttending to each row of NSTableview to change image on Click-
    primarykey
    data
    text
    <p>I'm trying to add <a href="http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/070-NSTableView-ImageAndTextCell.pl" rel="nofollow noreferrer">this</a> example's ImageAndTextCell.h class to my project. I have added it successfully. It looks something like below</p> <p><img src="https://i.imgur.com/3pTMrP5.png" alt="this"></p> <p>On row click i get the selected index and on IBAction I need to change it to green color. Which works fine too. But when I click on another row, the previous rows green turns to red. Im sure the problem is with the logic of checking for the row. I have implemented the below code which failed</p> <pre><code> - (NSCell *)tableView:(NSTableView *)tv dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSTextFieldCell *cell = [tableColumn dataCell]; if(tv== [self tableView]){ if([[tableColumn identifier] isEqualToString:COLUMN_TITLE]){ if(![tickTracker count]){ ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell; // Set the image here since the value returned from outlineView:objectValueForTableColumn:... didn't specify the image part... NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Cross" ofType:@"png"]; NSImage *markerImage = [[NSImage alloc] initWithContentsOfFile:fileName]; [imageAndTextCell setImage:markerImage]; }else{ for (int i= 0;i &lt; [tickTracker count];i++){ NSLog(@" 123 number %@",[tickTracker objectAtIndex:i]); NSInteger myInteger = [[tickTracker objectAtIndex:i] integerValue]; [changedRows addObject:[tickTracker objectAtIndex:i]]; if(row == myInteger){ NSLog(@" %li value ",row); ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell; // Set the image here since the value returned from outlineView:objectValueForTableColumn:... didn't specify the image part... NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Tick" ofType:@"png"]; NSImage *markerImage = [[NSImage alloc] initWithContentsOfFile:fileName]; [imageAndTextCell setImage:markerImage]; }else{ ImageAndTextCell *imageAndTextCell = (ImageAndTextCell *)cell; // Set the image here since the value returned from outlineView:objectValueForTableColumn:... didn't specify the image part... NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Cross" ofType:@"png"]; NSImage *markerImage = [[NSImage alloc] initWithContentsOfFile:fileName]; [imageAndTextCell setImage:markerImage]; } } } return cell; } </code></pre> <p>Can someone help me on this? The object at index 0 in tickTracker is not set to green when it checks for object at index 1. </p> <p><strong>EDIT 1</strong>. Inside the ticktracker: </p> <p>-(IBAction)method:(id)sender{</p> <pre><code> NSUInteger idx = [[tableView selectedRowIndexes] firstIndex]; while (idx != NSNotFound) { int rowKey = (int)idx; NSNumber* rowNumber = [NSNumber numberWithInt:rowKey]; [tickTracker addObject:rowNumber]; idx =[[tableView selectedRowIndexes] indexGreaterThanIndex:idx]; } </code></pre> <p>}</p> <p>Ouput:</p> <pre><code> NSLog(@" 123 number %@",[tickTracker objectAtIndex:i]); Output: 123 number 2 NSLog(@" %li value ",row); 2 value </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload