How To Compare CGPoints In Fast?

I have 2 CGPointlike:

let a : CGPoint = CGPointMake(1, 1)
let b : CGPoint = CGPointMake(1, 1)

If both are the same, I want to do something.

This is just an example, but I want to compare this two CGPoint, and I found this question that has already been asked, but it is in objective-C, so anybudy can tell me how I can do it quickly?

+4
source share
2 answers

CGPointalready implements the protocol Equatable, so you can compare using the operator ==:

if a == b {
}
+9
source

A small example for you:

let a : CGPoint = CGPointMake(1, 1)
let b : CGPoint = CGPointMake(1, 1)

if (a == b)
{
  var str = "YES"
}
+5
source

All Articles