NextPrevUpTopContentsIndex

1.3.9 Selectors

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")

then

(selector-name *selector*)

will return the string "frame" .


LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 4 Apr 2005

NextPrevUpTopContentsIndex