Some Objective-C methods have arguments or values of type
SEL
, which is a pointer type used to represent selectors. These can be used in Lisp as foreign pointers of type sel, which can be obtained from a string by calling coerce-to-selector. The function selector-name can be used to find the name of a selector.
For example, a call in Objective-C such as:
[foo respondsToSelector:@selector(frame)]
could be written using can-invoke-p as in Determining whether a method exists or using selectors as follows:
(invoke foo "respondsToSelector:" (coerce-to-selector "frame"))
If
*selector*
is bound to the result of calling
(coerce-to-selector "frame")
(selector-name *selector*)
will return the string
"frame"
.