Edit AllPages

This is a Foundation Framework function used to convert the name of a method into the actual selector, which you can then use to test if a certain object has that method which you want to call (using the NSObject method respondsToSelector).


SEL NSSelectorFromString(NSString *aSelectorName)

Apple Docs: (scroll to NSSelectorFromString)

The pages seems to have moved. Is it the new address?

A simple example:

SEL method;

method = NSSelectorFromString(@”setObject:”);

Here we are assuming we have an object that has the method setObject:, note that the colons “:” must be included at the end of the string if and only if the method takes an argument. If it doesn’t, leave off the colon.

Use NSStringFromSelector to go the other way.