@@ -37,10 +37,10 @@ public final class CollectionViewDriver: NSObject {
37
37
}
38
38
}
39
39
40
- // avoiding a strong reference to prevent a retain cycle.
41
- // this is typically the view controller that owns `self` (the driver).
42
- // the caller is responsible for retaining this object for the lifetime of the driver.
43
- private unowned var _cellEventCoordinator : CellEventCoordinator
40
+ // Avoiding a strong reference to prevent a possible retain cycle.
41
+ // This is typically the view controller that owns `self` (the driver).
42
+ // The caller is responsible for retaining this object for the lifetime of the driver.
43
+ private weak var _cellEventCoordinator : CellEventCoordinator ?
44
44
45
45
private( set) var _dataSource : DiffableDataSource
46
46
@@ -56,8 +56,11 @@ public final class CollectionViewDriver: NSObject {
56
56
/// - view: The collection view.
57
57
/// - layout: The collection view layout.
58
58
/// - viewModel: The collection view model.
59
- /// - cellEventCoordinator: The cell event coordinator. **This object is not retained by the driver.**
60
- /// - animateUpdates: Specifies whether or not to animate updates. Pass `true` to animate, `false` otherwise.
59
+ /// - cellEventCoordinator: The cell event coordinator,
60
+ /// if you wish to handle cell events outside of your cell view models.
61
+ /// **Note: This object is not retained by the driver.**
62
+ /// - animateUpdates: Specifies whether or not to animate updates.
63
+ /// Pass `true` to animate, `false` otherwise.
61
64
/// - didUpdate: A closure to call when the driver finishes diffing and updating the collection view.
62
65
///
63
66
/// - Warning: The driver **does not** retain the `cellEventCoordinator`,
@@ -67,7 +70,7 @@ public final class CollectionViewDriver: NSObject {
67
70
public init ( view: UICollectionView ,
68
71
layout: UICollectionViewCompositionalLayout ,
69
72
viewModel: CollectionViewModel = CollectionViewModel ( ) ,
70
- cellEventCoordinator: CellEventCoordinator ,
73
+ cellEventCoordinator: CellEventCoordinator ? ,
71
74
animateUpdates: Bool = true ,
72
75
didUpdate: DidUpdate ? = nil ) {
73
76
self . view = view
0 commit comments