All Manuals > LispWorks Delivery User Guide > 6 Delivery on Mac OS X

NextPrevUpTopContentsIndex

6.9 Retaining Objective-C classes

If you implement an Objective-C class in Lisp but its name is not referenced at runtime, then you need to arrange for this symbol to be retained during delivery.

This can be achieved with :keep-symbols, but a more modular approach is to keep the name on the plist of some other symbol. For example the internal CAPI class lw-slider is defined like this:

(objc:define-objc-class lw-slider ()
    ()
  (:objc-class-name "LWSlider")
  (:objc-superclass-name "NSSlider"))

and lw-slider is retained like this:

(setf (get 'slider-representation 'owner-class)
      'lw-slider)

In this case, the code for slider-representation is the only thing that makes the LWSlider object, so it is the best place to retain it (that is, only if slider-representation is retained).


LispWorks Delivery User Guide - 15 Feb 2015

NextPrevUpTopContentsIndex