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.7 Instance variables

In a few cases, for instance when using nib files created by Apple's Interface Builder, it is necessary to add Objective-C instance variables to a class. This can be done using the :objc-instance-vars class option to define-objc-class. For example, the following class contains two instance variables, each of which is a pointer to an Objective-C foreign object:

(define-objc-class my-controller ()
  ()
  (:objc-class-name "MyController")
  (:objc-instance-vars
   ("widthField" objc:objc-object-pointer)
   ("heightField" objc:objc-object-pointer)))

Given an instance of my-controller , the instance variables can be accessed using the function objc-object-var-value.


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

NextPrevUpTopContentsIndex