Sunday, January 7, 2018

ios How to remove an object from array of tuples

ios How to remove an object from array of tuples




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 cant figure out how index of tuple!

i tried this, doesnt 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

go to link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.