Is it possible to cancel a collision before it happens in the space?

**Example**: A and B is about to collide but A has a property so that the collision with B should not take place for the specific SKPhysicsContact. All other collisions in the space should be unaffected.

When reading Apple´s documentation for the class it says:

> 
> The physics contact delegate methods are called during the physics
>  simulation step. During that time, the physics world can't be modified
>  and the behavior of any changes to the physics bodies in the
>  simulation is undefined. If you need to make such changes, set a flag
>  inside didBegin(*:) or didEnd(*:) and make changes in response to that
>  flag in the update(\_:for:) method in a SKSceneDelegate.
> 
> 
> 

Does this mean I can detect the state in *didBegin()* and change the collision mask in *update()* before the actual collision is a fact?

There is an older thread with a similar topic: [SpriteKit SKPhysicsBody collision in one direction like a door you can only go through but not back](https://stackoverflow.com/questions/35362810/spritekit-skphysicsbody-collision-in-one-direction-like-a-door-you-can-only-go-t)