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

define-objc-class-method Macro

Summary

Defines an Objective-C class method for a specified class.

Package

objc

Signature

define-objc-class-method (name result-type &optional result-style) (object-argspec {argspec}*) {form}*

object-argspec ::= (object-var class-name [pointer-var])

argspec ::= (arg-var arg-type [arg-style])

Arguments
name
A string naming the method to define.
result-type
An Objective-C FLI type.
result-style
An optional keyword specifying the result conversion style, either :lisp or :foreign.
form
A form.
object-var
A symbol naming a variable.
class-name
A symbol naming a class defined with define-objc-class.
pointer-var
An optional symbol naming a variable.
arg-var
A symbol naming a variable.
arg-type
An Objective-C FLI type.
arg-style
An optional symbol or list specifying the argument conversion style.
Description

The macro define-objc-class-method defines the Objective-C class method name for the Objective-C classes associated with class-name. name should be a concatenation of the message name and its argument names, including the colons, for example "setWidth:height:".

If the define-objc-class definition of class-name specifies the (:objc-class-name objc-class-name) option, then the method is added to the Objective-C class objc-class-name. Otherwise, the method is added to the Objective-C class of every subclass of class-name that specifies the :objc-class-name option, allowing a mixin class to define methods that become part of the implementation of its subclasses (see 1.4.6 Abstract classes).

When the method is invoked, each form is evaluated in sequence with object-var bound to the (sub)class of class-name, pointer-var (if specified) bound to the receiver foreign pointer to the Objective-C class and each arg-var bound to the corresponding method argument.

See define-objc-method for details of the argument and result conversion (using arg-type, arg-style, result-type and result-style).

forms can use functions such as invoke to invoke other class methods on pointer-var. The macro current-super can be used to obtain an object that allows class methods in the superclass to be invoked (like super in Objective-C).

See also

define-objc-class
define-objc-method
current-super


LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 01 Dec 2021 19:38:32