NSSelectorFromString(_:)
Returns the selector with a given name.
Declaration
func NSSelectorFromString(_ aSelectorName: String) -> SelectorParameters
- aSelectorName:
A string of any length, with any characters, that represents the name of a selector.
Return Value
The selector named by aSelectorName. If aSelectorName is nil, or cannot be converted to UTF-8 (this should be only due to insufficient memory), returns (SEL)0.
Discussion
To make a selector, NSSelectorFromString(_:) passes a UTF-8 encoded character representation of aSelectorName to sel_registerName(_:) and returns the value returned by that function. Note, therefore, that if the selector does not exist it is registered and the newly-registered selector is returned.
Recall that a colon (”:”) is part of a method name; setHeight is not the same as setHeight:.