UIResponder and Swift 2.0

I was revisiting an older Swift 1.0 project this morning, and discovered that, in the upgrade to Swift 2.0, it had become hilariously uncompilable. The automatic converter worked, frankly, better than I expected, but I was still left with a couple of head-scratching errors. The most confusing was that my SpriteKit subclasses no longer seemed to override their parent UIResponder methods:

No, Xcode, I'm pretty sure it does.

No, Xcode, I’m pretty sure it does.

My touches* methods don’t seem to have the right signature anymore. Turns out, I’d implemented them all as:

Either Swift 1.1 was more relaxed when it came to matching method signatures or the signatures of these methods changed in iOS 9, because the solution turned out to be to change the method signatures to take a set of UITouch objects and an optional event, e.g.:

Leave a Reply

Your email address will not be published. Required fields are marked *