diff --git a/DTGridView.m b/DTGridView.m index 7b2b778..146609f 100644 --- a/DTGridView.m +++ b/DTGridView.m @@ -199,7 +199,13 @@ - (void)addCellWithInfo:(NSObject *)info { if (![info isMemberOfClass:[DTGridViewCellInfo class]]) return; - [cellInfoForCellsOnScreen addObject:info]; + NSUInteger idx = [cellInfoForCellsOnScreen indexOfObjectPassingTest:^BOOL(DTGridViewCellInfo *i, NSUInteger idx, BOOL *stop) { + return info.xPosition == i.xPosition && info.yPosition == i.yPosition; + }]; + if(idx == NSNotFound) + [cellInfoForCellsOnScreen addObject:info]; + else + [cellInfoForCellsOnScreen replaceObjectAtIndex:idx withObject:info]; [cellInfoForCellsOnScreen sortUsingFunction:intSort context:NULL];