Say we are in an instance of SomeClass, consider this simple call
"FixerNote".does( #selector(SomeClass.fixer(_:)) )
public extension String
.. here, you need the actual SomeClass that called us .. ,
It's generally possible to iterate the stack trace of a program, but you need debug symbols to figure out where the
self parameter of a method lives, and it might not even be anywhere anymore on an optimized build, or the caller might have been inlined, or have suffered some other destructive fate at the whim of the optimizer. So while it's possible to get an approximation of what method called you, it's not possible to get the
self parameter of your caller on a deployed, symbol-less, optimized build.
And no, it's not possible to get a class out of a selector either. A selector is really just a string that identifies a method name, like "fixer:". The
#selector() syntax only ensures that the compiler generates the correct selector name for a method (considering eventual
@objc annotations) and helps refactoring tools understand what is happening.