ios - How to remove an object from array of tuples -
i larn swift , find limited functionality of arrays annoying.
consider next array of tuples:
var points = array<(touch: uitouch, startpoint: cgpoint)>() is there painless way remove particular object array?
the closest thing removeatindex method, though can't figure out how index of tuple!
i tried this, doesn't seem working tuples, not equatable:
self.points.removeatindex(int(find(self.points, point)))
this might way it:
let point1 = (touch: uitouch(), startpoint: cgpoint(x: 0, y: 0)) allow point2 = (touch: uitouch(), startpoint: cgpoint(x: 1, y: 1)) var points: [(touch: uitouch, startpoint: cgpoint)] = [] points += [point1, point2] // delete point2 points = points.filter { !($0.touch == point2.touch && $0.startpoint == point2.startpoint) } ios swift tuples
No comments:
Post a Comment