2

I have the following initWithCoder implementation which depends on the callback of the datasource method. But somehow the datasource is nil and the datasource methods aren't called. I'm using a storyboard and therefor have overwritten the initWithCoder-Method.

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSUInteger rows = 0;
        NSUInteger columns = 0;

        if (self.dataSource && [self.dataSource respondsToSelector:@selector(numberOfHeaderRowsInSpreadSheetView:)]) {
            rows = [self.dataSource numberOfHeaderRowsInSpreadSheetView:self];
        }
        if (self.dataSource && [self.dataSource respondsToSelector:@selector(numberOfHeaderColumnsInSpreadSheetView:)]) {
            columns = [self.dataSource numberOfHeaderColumnsInSpreadSheetView:self];
        }
        [self setupWithNumberOfHeaderRows:rows numberOfHeaderColumns:columns];
    }
    return self;
}

Does anybody has a clue?

Thanks in advance.

Moonstar
  • 247
  • 1
  • 4
  • 13
  • 1
    According to @ZevEisenberg answer, every attribute should be nil in that class cause the connections haven't been made yet. – Patrick Bassut Apr 22 '14 at 05:54

1 Answers1

2

I wouldn’t be surprised if the storyboard connections haven’t been made yet in -initWithCoder: (although I haven’t tested it). Try doing your checks later, like in viewWillAppear:.

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
  • +1 My problem is slightly related to the op's. But you still got me going by explaining what might be happening under the hood. All my classes attributes were nil in initWithCoder, Then I did my initializations in viewDidAppear, and non-nils were there. – Patrick Bassut Apr 22 '14 at 05:49