LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual > 1 Introduction to the Objective-C Interface > 1.4 Defining Objective-C classes and methods

NextPrevUpTopContentsIndex

1.4.5 Invoking methods in the superclass

Within the body of a define-objc-method or define-objc-class-method form, the local macro current-super can be used to obtain a special object which will make invoke call the method in the superclass of the defining class. This is equivalent to using super in Objective-C.

For example, the Objective-C code:

@implementation MySpecialObject
- (unsigned int)areaOfWidth:(unsigned int)width
                height:(unsigned int)height
{
  return 4*[super areaOfWidth:width height:height];
}
@end

could be written as follows in Lisp:

(define-objc-method ("areaOfWidth:height:" (:unsigned :int))
    ((self my-special-object)
     (width (:unsigned :int))
     (height (:unsigned :int)))
  (* 4 (invoke (current-super) "areaOfWidth:height:"
                               width height)))

LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex