Open
Description
It is common in Cocoa API for a method to have an “out parameter”, e.g. an NSError **
parameter that is used to return an error when a call fails.
Taking the deserialisation method in NSJSONSerialization
for example, this method
+ (id)JSONObjectWithData:(NSData *)data
options:(NSJSONReadingOptions)opt
error:(NSError **)error
can be called like this in Objective-C:
NSError *err = nil;
id obj = [NSJSONSerialization JSONObjectWithData:data options:0 error:&err];
And the equivalent with Rubicon-objc would be
from ctypes import byref, c_void_p
err = c_void_p(0)
obj = NSJSONSerialization.JSONObjectWithData_options_error_(
data, 0, byref(err),
)
NB: err = None
will not work since byref
expects a ctypes instance, and does not automatically convert None
to a NULL pointer.