chickadee » objc » objc:add-method

objc:add-method CLASS METHOD TYPES PROCprocedure
objc:add-class-method CLASS METHOD TYPES PROCprocedure

Adds a class or instance method to CLASS.

METHODMethod name as a string (e.g. "setWidth:height:")
TYPESList of encoded argument type strings (such as objc:INT or "@").
PROCScheme procedure representing the method.

The structure of the TYPES list is (RETURN-TYPE SELF SELECTOR METHOD-ARGS...).

You may add Scheme methods to pure Objective C classes; when class proxies are enabled, this will automatically taint the class so that safe calls are used. Currently, a warning is printed when a class is tainted.

(objc:define-method MyClass DBL ((sel1: INT i) (sel2: DBL d)) 
                                (print i) (+ i d)) 
(objc:add-method MyClass "sel1:sel2:"
                 (list objc:DBL objc:ID objc:SEL objc:INT objc:DBL) 
                 (lambda (self sel i d) (print i) (+ i d)))