All Manuals > LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual > 2 Objective-C Reference

standard-objc-object Abstract Class

Summary

The class from which all classes that implement an Objective-C class should inherit.

Package

objc

Superclasses

standard-object

Initargs
:init-function
An optional function that is called to initialize the Objective-C foreign object.
:pointer
An optional Objective-C foreign object pointer for the object.
Readers

objc-object-pointer

Description

The abstract class standard-objc-object provides the framework for subclasses to implement an Objective-C class. Subclasses are typically defined using define-objc-class, which allows the Objective-C class name to be specified. Instances of such a subclass have an associated Objective-C foreign object whose pointer can be retrieved using the objc-object-pointer accessor. The function objc-object-from-pointer can be used to obtain the object again from the Objective-C foreign pointer.

There are two ways that subclasses of standard-objc-object can be made:

Examples
(objc:define-objc-class my-view ()
  ()
  (:objc-class-name "MyView")
  (:objc-superclass-name "NSView"))
(defun my-view-init-function (pointer &key frame)
  (objc:invoke pointer "initWithFrame:" frame))
(make-instance 'my-view
               :init-function 'my-view-init-function
               :frame #(0 0 100 50)
               :allow-other-keys t)))

Note that :allow-other-keys t is needed because :frame is not a known initarg for my-view.

See also

define-objc-class
objc-object-destroyed
objc-object-from-pointer
objc-object-pointer


LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 18 Feb 2025 15:39:48