In my app, I need to store a single PKStroke and then be able to find it in a canvasView.drawing.strokes
array and modify it.
If I'm correct, I need PKStroke to conform to Equatable protocol.
I've found two ways of doing it:
//1.
extension PKStroke: Equatable {
public static func ==(lhs: PKStroke, rhs: PKStroke) -> Bool {
//We compare date and the number of points
return lhs.path.creationDate == rhs.path.creationDate &&
lhs.path.count == rhs.path.count
}
}
//OR
//2.
extension PKStroke: Equatable {
public static func ==(lhs: PKStroke, rhs: PKStroke) -> Bool {
//We get strokes as references and compare them for identity
return (lhs as PKStrokeReference) === (rhs as PKStrokeReference)
}
}
Maybe both ways are wrong. Could you point me in the right direction?