There are some functions which take as an argument @selector(methodName). I used NSLog to find out what @selector is, and it returns an integer. It looks like a PID, but when I ran ps ax that PID could not be found. What does that integer represent and why do we have to use @selector all the time instead of just passing the method name?
There are some functions which take as an argument @selector(methodName). I used NSLog to
Share
@selector()is a compiler directive to turn whatever’s inside the parenthesis into aSEL. ASELis a type to indicate a method name, but not the method implementation. (For that you’d need a different type, probably anIMPor aMethod) Under-the-hood, aSELis implemented as achar*, although relying on that behavior is not a good idea. If you want to inspect whatSELyou have, the best way to do it is to turn it into anNSString*like this:(Assuming you know that
_cmdis one of the hidden parameters of every method call, and is theSELthat corresponds to the current method)The Objective-C Programming Language Guide has much more information on the subject.