Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FirebaseDatabaseUI/FUIArray.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ - (void)invalidate {

// Remove all values on invalidation.
[self didUpdate];
for (NSInteger i = 0; i < self.snapshots.count; i++) {
for (NSInteger i = 0; i < self.snapshots.count; /* no i++ since we modify the array instead*/ ) {
FIRDataSnapshot *current = self.snapshots[i];

[self.snapshots removeObjectAtIndex:i];
Expand Down Expand Up @@ -269,7 +269,7 @@ - (id)objectAtIndexedSubscript:(NSUInteger)index {
return [self snapshotAtIndex:index];
}

- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index{
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index {
@throw [NSException exceptionWithName:@"FUIArraySetIndexWithSubscript"
reason:@"Setting an object as FUIArray[i] is not supported."
userInfo:nil];
Expand Down
9 changes: 9 additions & 0 deletions FirebaseDatabaseUITests/FUIArrayTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,13 @@ - (void)testArraySendsMessagesAfterReceivingValueEvent {
XCTAssert(ended == 1, @"expected array to end updates exactly once");
}

- (void)testRemovesAllElementsWhenInvalidated {
[self.observable populateWithCount:10];
[self.firebaseArray invalidate];

XCTAssert(self.firebaseArray.count == 0,
@"Expected array to be empty after invalidation, instead got %ld elements",
self.firebaseArray.count);
}

@end