Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoa Question: How do I get a string representation of a SEL?

Is it possible, given a SEL to generate a string representation of the method it refers to?

For context:

I have an object instance initialized thusly:

-(id) initWithTarget:(id)object action: (SEL)action;

Within the instance I would like to echo the string name of the method referred to by SEL. How do I do that?

like image 415
dugla Avatar asked Jan 23 '23 02:01

dugla


2 Answers

NSStringFromSelector

Conversion in opposite direction is also possible

NSSelectorFromString

like image 87
Mihir Mathuria Avatar answered May 14 '23 03:05

Mihir Mathuria


Use sel_getName.

like image 27
fbrereto Avatar answered May 14 '23 03:05

fbrereto