Much, much better! …there is still a minor issue regarding “memory leaking”…but this is another story…
Stored properties and extensions: a pure Swift approach
Costantino Pistagna

This can be solved by wrapping weak resference to self inside another object and watching for didSet property till it becomes nil. Once it becomes nil we can remove the object from the static map. Hope that it might work?