Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Changing to lazy load from accessor.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielctull committed Oct 29, 2010
1 parent 0a47fe1 commit 2ec82bd
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions DTGridView/DTGridView.m
Expand Up @@ -9,6 +9,9 @@
#import "DTGridView.h"
#import "DTGridViewCellInfoProtocol.h"

NSInteger const DTGridViewInvalid = -1;


@interface DTGridViewCellInfo : NSObject <DTGridViewCellInfoProtocol> {
NSInteger xPosition, yPosition;
CGRect frame;
Expand Down Expand Up @@ -99,6 +102,10 @@ - (void)awakeFromNib {
}

- (void)dctInternal_setupInternals {
numberOfRows = DTGridViewInvalid;
columnIndexOfSelectedCell = DTGridViewInvalid;
rowIndexOfSelectedCell = DTGridViewInvalid;

gridRows = [[NSMutableArray alloc] init];
rowPositions = [[NSMutableArray alloc] init];
rowHeights = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -131,8 +138,6 @@ - (void)reloadData {
}

- (void)drawRect:(CGRect)rect {
columnIndexOfSelectedCell = -1;
rowIndexOfSelectedCell = -1;

oldContentOffset = CGPointMake(0.0, 0.0);

Expand Down Expand Up @@ -759,5 +764,17 @@ - (void)gridViewCellWasTouched:(DTGridViewCell *)cell {
[self.delegate gridView:self selectionMadeAtRow:cell.yPosition column:cell.xPosition];
}


#pragma mark -
#pragma mark Accessors

- (NSInteger)numberOfRows {
if (numberOfRows = DTGridViewInvalid) {
numberOfRows = [self.dataSource numberOfRowsInGridView:self];
}

return numberOfRows;
}

@end

0 comments on commit 2ec82bd

Please sign in to comment.