@@ -33,10 +33,10 @@ open class ContinuesTouchCollectionViewCell: UICollectionViewCell {
33
33
/// Delegate that informs about touch state changes.
34
34
public weak var delegate : ContinuesTouchCollectionViewCellDelegate ?
35
35
36
- /// Assigned touch id if cell is being touched.
37
- fileprivate var touchID : String ? {
36
+ /// Assigned touch if cell is being touched.
37
+ public fileprivate( set ) var touch : UITouch ? {
38
38
didSet {
39
- isTouching = touchID != nil
39
+ isTouching = touch ? . touchID != nil
40
40
}
41
41
}
42
42
@@ -72,7 +72,7 @@ open class ContinuesTouchCollectionView: UICollectionView {
72
72
if let indexPath = indexPathForItem ( at: location) ,
73
73
let cell = cellForItem ( at: indexPath) as? ContinuesTouchCollectionViewCell ,
74
74
!cell. isTouching {
75
- cell. touchID = touch. touchID
75
+ cell. touch ? = touch
76
76
touchingCells. append ( cell)
77
77
}
78
78
}
@@ -89,16 +89,16 @@ open class ContinuesTouchCollectionView: UICollectionView {
89
89
let cell = cellForItem ( at: indexPath) as? ContinuesTouchCollectionViewCell ,
90
90
!cell. isTouching {
91
91
92
- if let untouchingCell = touchingCells. filter ( { $0. touchID == touch. touchID } ) . first {
92
+ if let untouchingCell = touchingCells. filter ( { $0. touch ? . touchID == touch. touchID } ) . first {
93
93
untouchingCells. append ( untouchingCell)
94
94
}
95
95
96
- cell. touchID = touch. touchID
96
+ cell. touch = touch
97
97
touchingCells. append ( cell)
98
98
}
99
99
}
100
100
101
- untouchingCells. forEach ( { $0. touchID = nil } )
101
+ untouchingCells. forEach ( { $0. touch = nil } )
102
102
touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
103
103
}
104
104
@@ -107,12 +107,12 @@ open class ContinuesTouchCollectionView: UICollectionView {
107
107
var untouchingCells = [ ContinuesTouchCollectionViewCell] ( )
108
108
109
109
for touch in touches {
110
- if let untouchingCell = touchingCells. filter ( { $0. touchID == touch. touchID } ) . first {
110
+ if let untouchingCell = touchingCells. filter ( { $0. touch ? . touchID == touch. touchID } ) . first {
111
111
untouchingCells. append ( untouchingCell)
112
112
}
113
113
}
114
114
115
- untouchingCells. forEach ( { $0. touchID = nil } )
115
+ untouchingCells. forEach ( { $0. touch = nil } )
116
116
touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
117
117
}
118
118
@@ -121,12 +121,12 @@ open class ContinuesTouchCollectionView: UICollectionView {
121
121
var untouchingCells = [ ContinuesTouchCollectionViewCell] ( )
122
122
123
123
for touch in touches {
124
- if let untouchingCell = touchingCells. filter ( { $0. touchID == touch. touchID } ) . first {
124
+ if let untouchingCell = touchingCells. filter ( { $0. touch ? . touchID == touch. touchID } ) . first {
125
125
untouchingCells. append ( untouchingCell)
126
126
}
127
127
}
128
128
129
- untouchingCells. forEach ( { $0. touchID = nil } )
129
+ untouchingCells. forEach ( { $0. touch = nil } )
130
130
touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
131
131
}
132
132
}
0 commit comments