dClass = objc_allocateClassPair(objc_lookUpClass("NSObject"), "PB_Delegate", 0)
the same as this:
d = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
dClass = CocoaMessage(0, d, "class")
Not quite. The first creates a new class named PB_Delegate
, while the second instantiates the sharedApplication
object and class, which are the same ones used by the PureBasic application. Nonetheless, in the contextual implementation, they both perform the same function.
However, the reported IMA-issue during device-removal has nothing to do with these delegations. As Shardik had suggested, de-initialising the activeScanner
variable, should arrest the issue:
ProcedureC didRemoveDeviceInBrowser(object.i, selector.i, deviceBrowser.i, removedDevice.i, moreGoing.i)
Debug "device removed in browser..."
CocoaMessage(0, removedDevice, "requestCloseSession")
CocoaMessage(0, removedDevice, "setDelegate:", 0)
RemoveGadgetItem(#scannerList, selectedScanner - 1)
ReDim scanners(ArraySize(scanners()) - 1)
If removedDevice = activeScanner
activeScanner = 0
Hope it works for you.