IF you are using simple categories, with each physics body belonging to only one category, then this alternative form of didBeginContact may be more readable:
func didBeginContact(contact: SKPhysicsContact) {
let contactMask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask
...