diff --git a/Parchment/Classes/PagingController.swift b/Parchment/Classes/PagingController.swift index 31d39695..74166b29 100644 --- a/Parchment/Classes/PagingController.swift +++ b/Parchment/Classes/PagingController.swift @@ -259,12 +259,15 @@ final class PagingController: NSObject { animated: false ) - collectionView.selectItem( - at: visibleItems.indexPath(for: pagingItem), - animated: false, - scrollPosition: options.scrollPosition - ) - + DispatchQueue.main.async { [weak self] in + guard let self, let indexPath = self.visibleItems.indexPath(for: pagingItem) else { return } + self.collectionView.selectItem( + at: indexPath, + animated: false, + scrollPosition: self.options.scrollPosition + ) + } + default: break } diff --git a/Parchment/Classes/PagingOptions.swift b/Parchment/Classes/PagingOptions.swift index 7c538f70..a73be991 100644 --- a/Parchment/Classes/PagingOptions.swift +++ b/Parchment/Classes/PagingOptions.swift @@ -1,6 +1,6 @@ import UIKit -public struct PagingOptions { +public struct PagingOptions: @unchecked Sendable { /// The size for each of the menu items. _Default: /// .sizeToFit(minWidth: 150, height: 40)_ public var menuItemSize: PagingMenuItemSize