Declare Help

I’m finally making progress on my iOS application. I am connecting to a Linea Pro barcode scanner. I finally have a connection state event being thrown but my barcodeData event is not. Both are added via AddHandler. Definition below. Am I declaring something wrong?

[code]’ /**
’ Notification sent when barcode is successfuly read. This notification is used when barcode type is set to BARCODE_TYPE_DEFAULT or BARCODE_TYPE_EXTENDED.
@param barcode - string containing barcode data
@param type - barcode type, one of the BAR_* constants
’ **/
’ -(void)barcodeData:(NSString *)barcode type:(int)type;

Public Sub BarcodeData(oObject as BTDeviceDelegate, barcode as text, type as integer)
//Never gets called
lblBarcode.text = "Barcode: " + barcode + " Type: " + Type.ToText
End Sub[/code]

They are setup in the Open event of my view:

[code]dim oDTDelegate as new BTDeviceDelegate
if oDTDelegate.isNil = false then
setDelegate_(app.oScanner.GetPtr, oDTDelegate)

AddHandler oDTDelegate.BarcodeData, Addressof BarcodeData
AddHandler oDTDelegate.ConnectionState, AddressOf ConnectionState

end if[/code]

And is there any way to tell if the delegate is get called but my declaration is wrong?

I don’t think NSString can be converted as easily to Text.

Public Sub BarcodeData(oObject as BTDeviceDelegate, barcode as NSString, type as integer)

Well, I’m using the Delegate method that UIKit is using and I think that’s where my initial works needs to be done in figuring that out. So that BarcodeData will have to be after the delegate handler has gotten the message and THEN I can call this method.

Very frustrating with lack of documentation.

Could you show the code with which you register both delegate methods on your delegate?

Thats right. CFStringRef converts implicitely to String and Text.

We got the issue resolved through PM. The problem turned out to be that no reference was being kept to the delegate so it went out of scope and never received the events.

Yup, the problem was between the computer and chair. Thanks again Jason for helping out. :slight_smile:

The other thing that I discovered was that the method signature (or whatever it’s called) was wrong:

The Obj C definition:
-(void)barcodeData:(NSString *)barcode type:(int)type;

Declaring the method helper in my app:
methods.Append new TargetClassMethodHelper(“barcodeData:type:”, AddressOf impl_barcodeDatatype, “v:*i”)