Permalink
Browse files

variable initialisation to keep clang happy/quiet

  • Loading branch information...
1 parent 0ccf34c commit 991343a59625fea261563890f5f8acbae794c4f7 @aufflick aufflick committed Oct 21, 2010
Showing with 27 additions and 3 deletions.
  1. +27 −3 DTGridView/DTGridView.m
View
30 DTGridView/DTGridView.m
@@ -200,6 +200,18 @@ - (void)addCellWithInfo:(NSObject<DTGridViewCellInfoProtocol> *)info {
[[gridCells objectAtIndex:info.yPosition] replaceObjectAtIndex:info.xPosition withObject:cell];
[self insertSubview:cell atIndex:0];
+
+ // remove any existing view at this frame
+ for (UIView *v in self.subviews) {
+ if (v.frame.origin.x == cell.frame.origin.x &&
+ v.frame.origin.y == cell.frame.origin.y &&
+ v != cell)
+ {
+ [v removeFromSuperview];
+ break;
+ }
+ }
+
[cell release];
}
@@ -286,8 +298,8 @@ - (void)loadData {
NSMutableArray *cellInfoArrayRows = [[NSMutableArray alloc] init];
- CGFloat maxHeight;
- CGFloat maxWidth;
+ CGFloat maxHeight = 0;
+ CGFloat maxWidth = 0;
for (NSInteger i = 0; i < self.numberOfRows; i++) {
@@ -356,6 +368,18 @@ - (void)loadData {
self.gridCells = cellInfoArrayRows;
[cellInfoArrayRows release];
+ if ([self.subviews count] > [self.gridCells count]) {
+ // the underlying data must have reduced, time to iterate
+ NSSet *gridCellsSet = [NSSet setWithArray:self.gridCells];
+ NSArray *subviewsCopy = [self.subviews copy];
+
+ for (DTGridViewCell *cell in subviewsCopy) {
+ if (![gridCellsSet member:cell])
+ [cell removeFromSuperview];
+ }
+
+ [subviewsCopy release];
+ }
}
- (void)checkViews {
@@ -574,7 +598,7 @@ - (DTGridViewCell *)cellForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex
- (void)scrollViewToRow:(NSInteger)rowIndex column:(NSInteger)columnIndex scrollPosition:(DTGridViewScrollPosition)position animated:(BOOL)animated {
- CGFloat xPos, yPos;
+ CGFloat xPos = 0, yPos = 0;
CGRect cellFrame = [[[self.gridCells objectAtIndex:rowIndex] objectAtIndex:columnIndex] frame];

0 comments on commit 991343a

Please sign in to comment.