In object programming a "class" defines an object giving it properties and methods. Once an "instance" of the class is created then generally all calls are directed to the instance. However, I am not clear how the FFI in LCB directs method calls to the correct object.
I believe that when a new foreign instance is created an objcID pointer is returned to LCB and this may be stored in a variable. So with this in mind is the first parameter in a foreign handler definition always this local variable i.e. a pointer to the Objective-C object being addressed? Are subsequent parameters in the foreign handler definition the values passed to the method being called, filling in the places after the colons in the Objective-C method name?
The documentation :
Reading the documentation seems to imply that when calling a instance method that all is required is the -methodName:The Obj-C binding string
The Obj-C binding string has the following form:
"objc:[library>][class.](+|-)method[?thread]"
Here library specifies the name of the library or framework to bind to (if no library is specified a symbol from the engine executable or a library it is linked to is assumed).
Here class specifies the name of the class containing the method to bind to. If the method is an instance method, the class can be omitted, creating a 'dynamic binding', i.e. just resolving the selector.
Here method specifies the method name to bind to in standard Obj-C selector form, e.g. addTarget:action:forControlEvents:. If the method is a class method then prefix it with '+', if it is an instance method then prefix it with '-'.
Code: Select all
private foreign handler ObjC_IncrementScore(in pID_of_ScoreBoardObject as ObjcID, pIncrementBy as CUInt) /
returns optional CUInt binds to "objc:-IncrementTotalScore:"
Am I anywhere near to being correct ?
Many thanks for your patience and any light you may shine into the darkness....