Skip to content
Browse files

Changing to lazy load from accessor.

  • Loading branch information...
1 parent 0a47fe1 commit 2ec82bdc41f79ed0faa2a5ac719f1b246f3ca76b @danielctull committed Oct 29, 2010
Showing with 19 additions and 2 deletions.
  1. +19 −2 DTGridView/DTGridView.m
View
21 DTGridView/DTGridView.m
@@ -9,6 +9,9 @@
#import "DTGridView.h"
#import "DTGridViewCellInfoProtocol.h"
+NSInteger const DTGridViewInvalid = -1;
+
+
@interface DTGridViewCellInfo : NSObject <DTGridViewCellInfoProtocol> {
NSInteger xPosition, yPosition;
CGRect frame;
@@ -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];
@@ -131,8 +138,6 @@ - (void)reloadData {
}
- (void)drawRect:(CGRect)rect {
- columnIndexOfSelectedCell = -1;
- rowIndexOfSelectedCell = -1;
oldContentOffset = CGPointMake(0.0, 0.0);
@@ -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.
Something went wrong with that request. Please try again.