All Manuals > 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.4 How inheritance works

Defining an Objective-C class introduced the define-objc-class macro with the :objc-class-name class option for naming the Objective-C class. Since this macro is like defclass , it can specify any number of superclasses from which the Lisp class will inherit and also provides a way for superclass of the Objective-C class to be chosen:

For example, both of these definitions define an Objective-C class that inherits from MyObject , via my-object in the case of my-special-object and explicitly for my-other-object :

(define-objc-class my-special-object (my-object)
  ()
  (:objc-class-name "MySpecialObject"))
 
(define-objc-class my-other-object ()
  ()
  (:objc-class-name "MyOtherObject")
  (:objc-superclass-name "MyObject"))

The set of methods available for a given Objective-C class consists of those defined on the class itself as well as those inherited from its superclasses.


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

NextPrevUpTopContentsIndex