How to get the name or signature of the current method into an NSString?

cocoa, cocoa-touch, iphone, objective-c, uikit

Solution

Every method call also passes two hidden arguments: an `id` named `self` and a `SEL` named `_cmd`. You can use `NSStringFromSelector` to convert the method selector to an NSString:

NSStringFromSelector(_cmd);

Problem

Example: I have a method `-myFooBarMethod:withFoo:bar:moreFoo:` and inside the implementation of that method I want to dynamically get the name of it, like `@"-myFooBarMethod:withFoo:bar:moreFoo:` into an NSString. No hard-typing of the method signature. I feel that this has to do something with selectors. How could I get the name of the current method (the one that executes the code) as NSString?

Original source