Objc interface: NSError reference arguments
What is the proper way to invoke an Objective-C method that takes an NSError argument by reference if I want to check the NSError after the call completes?
Suppose, for example, that I want to invoke a method with a signature likethis:
initWithName:(NSString *)name
config: (SomeConfigurationClass*)config
error:(NSError *)error;
The Lispworks manual shows how to pass arguments by reference like this:
(defun get-result (object)
(fli:with-dynamic-foreign-objects ((result-value :int))
(objc:invoke object "getValueInto:" result-value)
(fli:dereference result-value)))
What type should the argument error take?
NSError is a class; the Objective-C manual says that the type named objc:objc-object-pointer represents instances of Objective-C classes. That suggests that I should be using something like
(fli:with-dynamic-foreign-objects ((err :objc-object-pointer))
(objc:invoke object "initWithName:config:error" my-name my-config err)
(fli:dereference err)))
...but the Lispworks compiler complains that objc-object-pointer is an illegal foreign type (I've tried writing the name various ways).
Using :pointer yields
Illegal instruction(4) [code 0] at 7FFF7DF731C2
Foreign code offset #x17 from symbol "_os_unfair_lock_recursive_abort"
module "/usr/lib/system/libsystem_platform.dylib" [ #x7FFF7DF6D000 ]
The examples in the Library are no help; the Objective-C method calls that take an error argument are called with NIL for that argument, which is then ignored.
I can of course pass NIL, as the examples do, but what's the right way to invoke the method if I want to be able to check the NSError argument after the method call?