Forum Archive

Querying returned NSError

Trizard

Hello,

I'm trying to query a NSError object returned from on an AVFoundation call by reference.
The ObjectiveC Definition is
+ (instancetype)deviceInputWithDevice:(AVCaptureDevice )device
error:(NSError
*)outError;

I tried many combinations and can't figure it out:

err = c_void_p()
print err
err1 = pointer(err)
print err1

A)
deviceInput2=ObjCClass('AVCaptureDeviceInput').deviceInputWithDevice_error_(self.inputDevice2, byref(err1) )
print err1
B)
deviceInput2=ObjCClass('AVCaptureDeviceInput').deviceInputWithDevice_error
(self._inputDevice2, err1 )
print err1

What I get is
c_void_p(None)

A) c_void_p(None)
B)

What is the right way to do this and to get the NSError in the end?

All examples I found just seem to ignore the NSError by using None.

Many thanks!

omz

Something like this should work:

err_ptr = c_void_p()
device_input = ObjCClass('AVCaptureDeviceInput').deviceInputWithDevice_error_(input_device, byref(err_ptr))
if err_ptr:
    err = ObjCInstance(err)
    print(err)