objective c - NSTableView cells are not getting data from the delegate method -
i working on simple tableview , stumped here. table view cells not getting data tableview:objectvaluefortablecolumn:row:
method.
i supposed this:
but getting this:
here .h , .m files of tablecontroller class
@interface tablecontroller : nsobject <nstableviewdatasource, nstableviewdelegate> @property (nonatomic, strong) nsarray *numbers; @property (nonatomic, strong) nsarray *numbercodes; @end
and
#import "tablecontroller.h" @implementation tablecontroller #pragma mark - custom initialisers - (nsarray *)numbers { if (!_numbers) { _numbers = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"]; } return _numbers; } - (nsarray *)numbercodes { if (!_numbercodes) { _numbercodes = @[@"one", @"two", @"three", @"four", @"five", @"six", @"seven", @"eight", @"nine", @"ten"]; } return _numbercodes; } -(nsinteger) numberofrowsintableview:(nstableview *)tableview{ nslog(@"what ho tally!"); return self.numbers.count; } -(id) tableview:(nstableview *)tableview objectvaluefortablecolumn:(nstablecolumn *)tablecolumn row:(nsinteger)row{ if ([tablecolumn.identifier isequaltostring:@"numbers"]) { nslog(@"%@", [self.numbers objectatindex:row]); // first colum (numbers) return [self.numbers objectatindex:row]; } else { nslog(@"%@", [self.numbercodes objectatindex:row]); // second column (numbercodes) return [self.numbercodes objectatindex:row]; } } @end
the objects in array getting nslogged properly. somehow not getting reflected in tableview.
thew following may further give more info...
i think need use tableview:setobjectvalue:fortablecolumn:row:
instead of -(id) tableview:(nstableview *)tableview objectvaluefortablecolumn:(nstablecolumn *)tablecolumn row:(nsinteger)row{
, no ?
edit :
in fact, in project, need set table view "cell based" content mode instead of "view based" mode , works !
Comments
Post a Comment