All Manuals > LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual > 1 Introduction to the Objective-C Interface > 1.3 Invoking Objective-C methods

NextPrevUpTopContentsIndex

1.3.8 Determining whether a method exists

In some cases, an Objective-C class might have a method that is optionally implemented and invoke will signal an error if the method is missing for a particular object. To determine whether a method is implemented, call the function can-invoke-p with the foreign object pointer or class name and the name of the method.

For example, a call in Objective-C such as:

[foo respondsToSelector:@selector(frame)]

could be written using can-invoke-p as:

(can-invoke-p foo "frame")

LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 15 Dec 2011

NextPrevUpTopContentsIndex