▼ |  | Objective-C FFI

1 | Using Unsafe Bindings
2 | FFI Types and Constants
3 | Syntactic Forms
4 | Raw Runtime Functions

On this page:

objc_ look Up Class
sel_ register Name
objc_ allocate Class Pair
objc_ register Class Pair
object_ get Class
class_ add Method
class_ add Ivar
object_ get Instance Variable
object_ set Instance Variable
_ Ivar
objc_ msg Send/ typed
objc_ msg Send Super/ typed
make-obj_ csuper
_ objc_ super

top ← prev up next →

### 4`` Raw Runtime Functions

(objc_lookUpClass s) → ( or/c _Class #f)
s : string?

Finds a registered class by name.

(sel_registerName s) → _SEL
s : string?

Interns a selector given its name in string form.

(objc_allocateClassPair cls s extra) → _Class
cls : _Class
s : string?
extra : integer?

Allocates a new Objective-C class.

(objc_registerClassPair cls) → void?
cls : _Class

Registers an Objective-C class.

(object_getClass obj) → _Class
obj : _id

Returns the class of an object (or the meta-class of a class).

( class_addMethod |  | cls |  |  |  |
|  | sel |  |  |  |
|  | imp |  |  |  |
|  | type |  |  |  |
|  | type-encoding) |  | → |  | boolean?

cls : _Class
sel : _SEL
imp : procedure?
type : ctype?
type-encoding : string?

Adds a method to a class. The type argument must be a FFI C type (see Type Constructors) that matches both imp and and the not Objective-C type string type-encoding.

(class_addIvar |  | cls |  |  |  |
|  | name |  |  |  |
|  | size |  |  |  |
|  | log-alignment |  |  |  |
|  | type-encoding) |  | → |  | boolean?

cls : _Class
name : string?
size : exact-nonnegative-integer?
log-alignment : exact-nonnegative-integer?
type-encoding : string?

Adds an instance variable to an Objective-C class.

(object_getInstanceVariable obj name)

→

_Ivar |  | any/c

obj : _id
name : string?

Gets the value of an instance variable whose type is _pointer.

(object_setInstanceVariable obj name val) → _Ivar
obj : _id
name : string?
val : any/c

Sets the value of an instance variable whose type is _pointer.

_Ivar : ctype?

The type of an Objective-C instance variable, an opaque pointer.

(( objc_msgSend/typed types) obj sel arg) → any/c
types : ( vector/c result-ctype arg-ctype ... )
obj : _id
sel : _SEL
arg : any/c

Calls the Objective-C method on _id named by sel. The types vector must contain one more than the number of supplied args; the first FFI C type in type is used as the result type.

(( objc_msgSendSuper/typed |  | types) |  |  |  |
|  | super |  |  |  |
|  | sel |  |  |  |
|  | arg) |  | → |  | any/c

types : ( vector/c result-ctype arg-ctype ... )
super : _objc_super
sel : _SEL
arg : any/c

Like objc_msgSend/typed, but for a super call.

(make-obj_csuper id super) → _objc_super
id : _id
super : _Class

_objc_super : ctype?

Constructor and FFI C type use for super calls.
top ← prev up next →