cocoa - NSOutlineView with 2 columns, text and check -


i have done :

that nsoutlineview 2 columns, first column textcell , on second column drag , drop check box cell. now, set true rows :

 -(id)outlineview:(nsoutlineview *)outlineview objectvaluefortablecolumn:(nstablecolumn *) tablecolumn byitem:(id)item {     if ([[tablecolumn identifier] isequaltostring:@"name"]) {         return [item name];     } else if ([[tablecolumn identifier] isequaltostring:@"sel"]) {         return @"1"; //for nsonstate                 //return @"0"; //for nsoffstate     } } 

now want when user click on checkbox go nsoffstate , try inside method :

 -(void)outlineview:(nsoutlineview *)outlineview setobjectvalue:(id)object fortablecolumn:(nstablecolumn *)tablecolumn byitem:(id)item {      [item setsel:nsoffstate]; } 

but don't go, how can ?

help me !!!

     #import       @interface appdelegate : nsobject  {         nsmutablearray *array;     }      @property (assign) iboutlet nswindow *window;      @end 
     #import "appdelegate.h"      @implementation appdelegate      @synthesize window = _window;      - (void)dealloc     {        [super dealloc];     }      - (void)applicationdidfinishlaunching:(nsnotification *)anotification     {         // insert code here initialize application     }      -(void)awakefromnib     {         array=[[[nsmutablearray alloc]init]autorelease];         nsmutabledictionary *dc=[nsmutabledictionary dictionary];          bool test=yes;         nsnumber *num=[nsnumber numberwithbool:test];          [dc setobject:num forkey:@"sel"];         [dc setobject:@"name" forkey:@"name"];          [array addobject:dc];     //[self setarray:self.array];      }       - (id)outlineview:(nsoutlineview *)outlineview child:(nsinteger)index ofitem:(id)item      {         return [array objectatindex:index];      }        - (bool)outlineview:(nsoutlineview *)outlineview isitemexpandable:(id)item      {         return no;      }       - (nsinteger)outlineview:(nsoutlineview *)outlineview numberofchildrenofitem:(id)item      {         return [array count];      }       - (id)outlineview:(nsoutlineview *)outlineview objectvaluefortablecolumn:(nstablecolumn       *)tablecolumn byitem:(id)item      {         if ([[tablecolumn identifier] isequaltostring:@"name"])      {         /*         nsstring *str=[item objectforkey:@"name"];         nslog(@"name=%@",str);*/         return @"name"; //str;      }         else if ([[tablecolumn identifier] isequaltostring:@"sel"])        {         /*         nsstring *str=[item objectforkey:@"sel"];         nsnumber *num=[nsnumber numberwithbool:[str boolvalue]];         nslog(@"sel=%@",num);*/         return @"0"; //num;        }      else          {          return nil;          }      }      - (void)outlineview:(nsoutlineview *)outlineview setobjectvalue:(id)object    fortablecolumn:(nstablecolumn *)tablecolumn byitem:(id)item      {        [item setvalue:object forkey:[tablecolumn identifier]];      }       @end 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -