insertItemsWithIdentifiers:afterItemWithIdentifier: and - insertSectionsWithIdentifiers:afterSectionWithIdentifier:, their behavior seems to be inconsistent.
(void)testInsertItemsWithIdentifiersAfterItemWithIdentifier_IfHasExist {
NSArray *items = @[@"1",@"2",@"3",@"5"];
NSArray *insertItems = @[@"3",@"4"];
NSArray *sections = @[@1,@2];
[self.snapshot appendSectionsWithIdentifiers:sections];
[self.snapshot appendItemsWithIdentifiers:items];
[self.snapshot insertItemsWithIdentifiers:insertItems afterItemWithIdentifier:@"5"];
NSArray *expect = @[@"1",@"2",@"3",@"5",@"4"];
XCTAssertEqualObjects([self.snapshot itemIdentifiers], expect);
}
It has a failure,because [self.snapshot itemIdentifiers] is 1,2,5,3,4
but on the other hand
NSArray *sections = @[@1,@2,@3,@5];
NSArray *insertSections = @[@3,@4];
[self.snapshot appendSectionsWithIdentifiers:sections];
[self.snapshot insertSectionsWithIdentifiers:insertSections afterSectionWithIdentifier:@5];
NSArray *expect = @[@1,@2,@3,@5,@4];
XCTAssertEqualObjects([self.snapshot sectionIdentifiers], expect);
}
It is success.