Forum Xamarin.iOS

Bindings - providing callback to Objective-C method which expects a Selector?

JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
edited October 2013 in Xamarin.iOS

In my binding library I've got an Objective-C selector:

 * postGetBattery
 * Creates a SktScanObject and initializes it to perform a request for the
 * battery level in the scanner.
-(void)postGetBattery:(DeviceInfo*)deviceInfo Target:(id)target Response:(SEL)response;

which I've bound as follows:

[Export ("postGetBattery:Target:Response:")]
void PostGetBattery (DeviceInfo deviceInfo, NSObject target, Selector response);

My problem now is how I call this in my Xamarin.iOS application - providing the resonse selector. Creating a C# method with what looks like the right signature:

    void onPostGetBatteryResponse (long result, ISktScanObject scanObject)
        if (!SktScanErrors.SKTSUCCESS ((int)result)) {
            throw new Exception (string.Format ("Error in onPostGetBatteryResponse: result={0}", result));

Produces the error:

/Users/james/P4/Novex Error CS1503: Argument `#3' cannot convert `method group' expression to type `MonoTouch.ObjCRuntime.Selector' (CS1503)

so presumably I have to either change/enhance my binding or create a selector associated with my callback method.

Can someone enlighten me please?

Best Answer


  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

    Thanks, that's just what I needed to know - to decorate the method with the correct Export.

Sign In or Register to comment.