I\'m writing a helper function in Swift for use in SpriteKit games that will check if the collision detention has been set up correctly.
I want to check that my GameScen
respondsToSelector fails, because it expects an instance of SKPhysicsContact and not SKPhysicsContact.type.
To check if an object implements an interface, you can use is. So for example:
protocol Test {
func foo();
}
class TestImpl : Test {
func foo() {
print("bar")
}
}
let a = TestImpl()
let b = String()
print(a is Test) // true
print(b is Test) // false