A class defined with define-objc-class has no methods associated with it by default, other than those inherited from the its ancestor classes. New methods can be defined (or overridden) by using the macros define-objc-method for instance methods and define-objc-class-method for class methods.
Note that the Lisp method definition form is separate from the class definition, unlike in Objective-C where it is embedded in the
block. Also, there is no Lisp equivalent of the
block: the methods of an Objective-C class are just those whose defining forms have been evaluated.
When defining a method, various things must be specified:
For example, a method that would be implemented in an Objective-C class as follows:
- (unsigned int)areaOfWidth:(unsigned int)width
could be defined in Lisp for instances of the
class from Defining an Objective-C class using the form:
(define-objc-method ("areaOfWidth:height:" (:unsigned :int))
(width (:unsigned :int))
(height (:unsigned :int)))
(* width height))
is bound to a Lisp object of type
are bound to non-negative integers. The area is returned to the caller as an integer.
LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 15 Dec 2011