'iOS 15 build by xcode 13 crash on collectionView performBatchUpdates

After updating xcode to xcode 13. My app start giving crash on the collectionview where it is using performBatchUpdates on ios 15.

It's working fine on lower ios version.

dispatch_async(dispatch_get_main_queue(), ^{
    [self.collectionView performBatchUpdates:^{
        [weakSelf.collectionView insertItemsAtIndexPaths:addedIndexPaths];
    } completion:^(BOOL finished) {
   

        // scroll to the last added asset, so the user can see the process of uploading.
        NSIndexPath *lastIndexPath = addedIndexPaths.lastObject;
        if (lastIndexPath) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [weakSelf.collectionView scrollToItemAtIndexPath:lastIndexPath
                                                atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
            });
        }
    }];
});

Did anybody facing some issue and got some solution with this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source