File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Parse/Internal/Object/OperationSet Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 6565- (void )setObject : (id )anObject forKey : (id <NSCopying >)aKey ;
6666- (void )setObject : (id )anObject forKeyedSubscript : (id <NSCopying >)aKey ;
6767- (void )removeObjectForKey : (id )aKey ;
68+ - (void )removeAllObjects ;
6869
6970@end
Original file line number Diff line number Diff line change @@ -166,6 +166,11 @@ - (void)removeObjectForKey:(id)key {
166166 self.updatedAt = [NSDate date ];
167167}
168168
169+ - (void )removeAllObjects {
170+ [self .dictionary removeAllObjects ];
171+ self.updatedAt = [NSDate date ];
172+ }
173+
169174// /--------------------------------------
170175#pragma mark - NSFastEnumeration
171176// /--------------------------------------
Original file line number Diff line number Diff line change @@ -103,6 +103,24 @@ - (void)testRemoveObjectForKey {
103103 XCTAssertNotEqualObjects (date, operationSet.updatedAt );
104104}
105105
106+ - (void )testRemoveAllObjects {
107+ PFOperationSet *operationSet = [[PFOperationSet alloc ] init ];
108+
109+ operationSet[@" yarr" ] = [PFSetOperation setWithValue: @" a" ];
110+ operationSet[@" yolo" ] = [PFAddOperation addWithObjects: @[ @" b" ]];
111+
112+ XCTAssertNotNil (operationSet[@" yarr" ]);
113+ XCTAssertNotNil (operationSet[@" yolo" ]);
114+ XCTAssertEqual (operationSet.count , 2 );
115+
116+ NSDate *date = operationSet.updatedAt ;
117+ [operationSet removeAllObjects ];
118+ XCTAssertNil (operationSet[@" yarr" ]);
119+ XCTAssertNil (operationSet[@" yolo" ]);
120+ XCTAssertEqual (operationSet.count , 0 );
121+ XCTAssertNotEqualObjects (date, operationSet.updatedAt );
122+ }
123+
106124- (void )testCopying {
107125 PFOperationSet *operationSet = [[PFOperationSet alloc ] init ];
108126 operationSet[@" yarr" ] = [PFSetOperation setWithValue: @" yolo" ];
You can’t perform that action at this time.
0 commit comments