File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ - (void)invalidate {
161161
162162 // Remove all values on invalidation.
163163 [self didUpdate ];
164- for (NSInteger i = 0 ; i < self.snapshots .count ; i++) {
164+ for (NSInteger i = 0 ; i < self.snapshots .count ; /* no i++ since we modify the array instead */ ) {
165165 FIRDataSnapshot *current = self.snapshots [i];
166166
167167 [self .snapshots removeObjectAtIndex: i];
@@ -269,7 +269,7 @@ - (id)objectAtIndexedSubscript:(NSUInteger)index {
269269 return [self snapshotAtIndex: index];
270270}
271271
272- - (void )setObject : (id )obj atIndexedSubscript : (NSUInteger )index {
272+ - (void )setObject : (id )obj atIndexedSubscript : (NSUInteger )index {
273273 @throw [NSException exceptionWithName: @" FUIArraySetIndexWithSubscript"
274274 reason: @" Setting an object as FUIArray[i] is not supported."
275275 userInfo: nil ];
Original file line number Diff line number Diff line change @@ -476,4 +476,13 @@ - (void)testArraySendsMessagesAfterReceivingValueEvent {
476476 XCTAssert (ended == 1 , @" expected array to end updates exactly once" );
477477}
478478
479+ - (void )testRemovesAllElementsWhenInvalidated {
480+ [self .observable populateWithCount: 10 ];
481+ [self .firebaseArray invalidate ];
482+
483+ XCTAssert (self.firebaseArray .count == 0 ,
484+ @" Expected array to be empty after invalidation, instead got %ld elements" ,
485+ self.firebaseArray .count );
486+ }
487+
479488@end
You can’t perform that action at this time.
0 commit comments