3 Syntactic Forms
(tell result-type obj-expr method-id) | ||||||||||||||||||||||||||
(tell result-type obj-expr arg ) | ||||||||||||||||||||||||||
|
Sends a message to the Objective-C object produced by obj-expr. When a type is omitted for either the result or an argument, the type is assumed to be _id, otherwise it must be specified as an FFI C type (see Type Constructors).
If a single method-id is provided with no arguments, then method-id must not end with :; otherwise, each method-id must end with :.
Examples: | ||
> (tell NSString alloc) | ||
#<cpointer:id> | ||
| ||
#<cpointer:id> |
(tellv obj-expr method-id) |
(tellv obj-expr arg ) |
Like tell, but with a result type _void.
(import-class class-id ) |
Defines each class-id to the class (a value with FFI type _Class) that is registered with the string form of class-id. The registered class is obtained via objc_lookUpClass.
Examples: |
> (import-class NSString) |
| |||||||||||||||||||||||||||||||||||||||||||||
|
Defines class-id as a new, registered Objective-C class (of FFI type _Class). The superclass-expr should produce an Objective-C class or #f for the superclass.
Each field-id is an instance field that holds a Scheme value and that is initialized to #f when the object is allocated. The field-ids can be referenced and set! directly when the method bodys. Outside the object, they can be referenced and set with get-ivar and set-ivar!.
Each method adds or overrides a method to the class (when mode is - or -a) to be called on instances, or it adds a method to the meta-class (when mode is + or +a) to be called on the class itself. All result and argument types must be declared using FFI C types (see Type Constructors). When mode is +a or -a, the method is called in atomic mode (see _cprocedure).
If a method is declared with a single method-id and no arguments, then method-id must not end with :. Otherwise, each method-id must end with :.
If the special method dealloc is declared for mode -, it must not call the superclass method, because a (super-tell dealloc) is added to the end of the method automatically. In addition, before (super-tell dealloc), space for each field-id within the instance is deallocated.
Examples: | |||||||||
|
self |
When used within the body of a define-objc-class method, refers to the object whose method was called. This form cannot be used outside of a define-objc-class method.
(super-tell result-type method-id) |
(super-tell result-type arg ) |
When used within the body of a define-objc-class method, calls a superclass method. The result-type and arg sub-forms have the same syntax as in tell. This form cannot be used outside of a define-objc-class method.
(get-ivar obj-expr field-id) |
Extracts the Scheme value of a field in a class created with define-objc-class.
(set-ivar! obj-expr field-id value-expr) |
Sets the Scheme value of a field in a class created with define-objc-class.
(selector method-id) |
Returns a selector (of FFI type _SEL) for the string form of method-id.
Examples: |
> (tellv button setAction: #:type _SEL (selector terminate:)) |