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 {
161
161
162
162
// Remove all values on invalidation.
163
163
[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 */ ) {
165
165
FIRDataSnapshot *current = self.snapshots [i];
166
166
167
167
[self .snapshots removeObjectAtIndex: i];
@@ -269,7 +269,7 @@ - (id)objectAtIndexedSubscript:(NSUInteger)index {
269
269
return [self snapshotAtIndex: index];
270
270
}
271
271
272
- - (void )setObject : (id )obj atIndexedSubscript : (NSUInteger )index {
272
+ - (void )setObject : (id )obj atIndexedSubscript : (NSUInteger )index {
273
273
@throw [NSException exceptionWithName: @" FUIArraySetIndexWithSubscript"
274
274
reason: @" Setting an object as FUIArray[i] is not supported."
275
275
userInfo: nil ];
Original file line number Diff line number Diff line change @@ -476,4 +476,13 @@ - (void)testArraySendsMessagesAfterReceivingValueEvent {
476
476
XCTAssert (ended == 1 , @" expected array to end updates exactly once" );
477
477
}
478
478
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
+
479
488
@end
You can’t perform that action at this time.
0 commit comments