単に==
enum Three {
case pointOne(point: CGPoint)
case pointTwo(point: CGPoint)
case pointThree(point: CGPoint)
func coordinatesXY() -> CGPoint {
switch self {
case .pointOne(let point): return point
case .pointTwo(let point): return point
case .pointThree(let point): return point
}
}
}
let point1 = CGPoint(x: 100, y: 100)
let point2 = CGPoint(x: 100, y: 100)
if point1 == point2{
print("yes")
}
Three.pointOne(point: point1).coordinatesXY() //Gives you a CGPoint
Three.pointTwo(point: point2)
func checkEquality(pointA : CGPoint, pointB : CGPoint){
if Three.pointOne(point: pointA).coordinatesXY() == Three.pointTwo(point: pointB).coordinatesXY(){
print("yes") //Prints yes
}
}
//Prototype of comparing two coordinates
var arrOne = [Three]()
var arrTwo = [Three]()
arrOne.append(Three.pointOne(point: point1))
arrOne.append(Three.pointOne(point: point1))
arrOne.append(Three.pointOne(point: point1))
arrOne.append(Three.pointOne(point: point1))
arrOne.append(Three.pointOne(point: point1))
arrOne.append(Three.pointOne(point: point1))
arrTwo.append(Three.pointTwo(point: point2))
arrTwo.append(Three.pointTwo(point: point2))
arrTwo.append(Three.pointTwo(point: point2))
arrTwo.append(Three.pointTwo(point: point2))
arrTwo.append(Three.pointTwo(point: point2))
arrTwo.append(Three.pointTwo(point: point2))
for eachA in arrOne{
let arrayOneElement = eachA.coordinatesXY()
for eachB in arrTwo{
let arrayTwoElement = eachB.coordinatesXY()
checkEquality(arrayOneElement, pointB: arrayTwoElement)
}
}
しかし、私はマウスでポイントをドラッグしていた座標」原因がわからない場合。 –
もう1つ質問:100ポイントを持ったらどうなりますか? )) –
for-inループを書くことができますか? –