@@ -33,10 +33,10 @@ open class ContinuesTouchCollectionViewCell: UICollectionViewCell {
3333 /// Delegate that informs about touch state changes.
3434 public weak var delegate : ContinuesTouchCollectionViewCellDelegate ?
3535
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 ? {
3838 didSet {
39- isTouching = touchID != nil
39+ isTouching = touch ? . touchID != nil
4040 }
4141 }
4242
@@ -72,7 +72,7 @@ open class ContinuesTouchCollectionView: UICollectionView {
7272 if let indexPath = indexPathForItem ( at: location) ,
7373 let cell = cellForItem ( at: indexPath) as? ContinuesTouchCollectionViewCell ,
7474 !cell. isTouching {
75- cell. touchID = touch. touchID
75+ cell. touch ? = touch
7676 touchingCells. append ( cell)
7777 }
7878 }
@@ -89,16 +89,16 @@ open class ContinuesTouchCollectionView: UICollectionView {
8989 let cell = cellForItem ( at: indexPath) as? ContinuesTouchCollectionViewCell ,
9090 !cell. isTouching {
9191
92- if let untouchingCell = touchingCells. filter ( { $0. touchID == touch. touchID } ) . first {
92+ if let untouchingCell = touchingCells. filter ( { $0. touch ? . touchID == touch. touchID } ) . first {
9393 untouchingCells. append ( untouchingCell)
9494 }
9595
96- cell. touchID = touch. touchID
96+ cell. touch = touch
9797 touchingCells. append ( cell)
9898 }
9999 }
100100
101- untouchingCells. forEach ( { $0. touchID = nil } )
101+ untouchingCells. forEach ( { $0. touch = nil } )
102102 touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
103103 }
104104
@@ -107,12 +107,12 @@ open class ContinuesTouchCollectionView: UICollectionView {
107107 var untouchingCells = [ ContinuesTouchCollectionViewCell] ( )
108108
109109 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 {
111111 untouchingCells. append ( untouchingCell)
112112 }
113113 }
114114
115- untouchingCells. forEach ( { $0. touchID = nil } )
115+ untouchingCells. forEach ( { $0. touch = nil } )
116116 touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
117117 }
118118
@@ -121,12 +121,12 @@ open class ContinuesTouchCollectionView: UICollectionView {
121121 var untouchingCells = [ ContinuesTouchCollectionViewCell] ( )
122122
123123 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 {
125125 untouchingCells. append ( untouchingCell)
126126 }
127127 }
128128
129- untouchingCells. forEach ( { $0. touchID = nil } )
129+ untouchingCells. forEach ( { $0. touch = nil } )
130130 touchingCells = touchingCells. filter ( { !untouchingCells. contains ( $0) } )
131131 }
132132}
0 commit comments