Post

Replies

Boosts

Views

Activity

Reply to reloadItems behavior on NSDiffableDataSourceSnapshot
I think reloadSections/reloadItems just calculate the items need to be reload and set the tag, it does not change the truth datasource array. The reload effect actually occurs when the dataSource's apply() call. It's behaviour may be like setNeedsLayout. I can only think of this reason to explain its current behavior.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’20
Reply to Why do they behave differently from each other ?
NSArray *sections = @[@"1",@"2",@"3",@"5"];     NSArray *insertSections = @[@"3",@"4"];     [self.stringSnapshot appendSectionsWithIdentifiers:sections];     [self.stringSnapshot insertSectionsWithIdentifiers:insertSections afterSectionWithIdentifier:@"5"];     NSArray *expect = @[@"1",@"2",@"3",@"5",@"4"];     XCTAssertEqualObjects([self.stringSnapshot sectionIdentifiers], expect);     NSArray *items = @[@"1",@"2",@"3",@"5"];     NSArray *insertItems = @[@"3",@"4"];     NSArray *sections = @[@1,@2];     [self.stringSnapshot appendSectionsWithIdentifiers:sections];     [self.stringSnapshot appendItemsWithIdentifiers:items];     [self.stringSnapshot insertItemsWithIdentifiers:insertItems afterItemWithIdentifier:@"5"];     NSArray *expect = @[@"1",@"2",@"3",@"5",@"4"];     XCTAssertEqualObjects([self.stringSnapshot itemIdentifiers], expect); I tried using strings in both cases, but the result is same as above.The same goes for Numbers.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’20
Reply to Why do they behave differently from each other ?
Duplicate items/sections is not the point.The same initial list @[@1,@2,@3,@5] and same insertion list @[@3,@4] and same toidentifier @5, why different between insertSectionsWithIdentifiers and insertItemsWithIdentifiers. It seem to ignore the duplicate section @3,only insert @4 when insertSectionsWithIdentifiers. but when insertItemsWithIdentifiers, it seem to move the @3,not ignore.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’20