Binding issue

starl1nstarl1n DOUniversity ✭✭
edited December 2018 in Xamarin.iOS

Hi everyone I'm trying to parse a library that connects via bluetooth to some printers and I facing an issue with the "return" of the method that open the connection and would like to know if someone can point me to the right direction:

The objective C method is the follow

  • (void)openPrinter:(NSString *)printerName
    completion:(DzDidOpenedPrinterBlock)completion;

On the Binding generated by Objective Sharpie I get the follow

// +(void)openPrinter:(NSString *)printerName completion:(DzDidOpenedPrinterBlock)completion;
    [Static]
    [Export ("openPrinter:completion:")]
    void OpenPrinter (string printerName, DzDidOpenedPrinterBlock completion);

I'm able to search for printers, but that method is returning the following error

[__NSArrayI objectOnIndex:]: unrecognized selector sent to instance 0x2828c1740
Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[__NSArrayI objectOnIndex:]: 
unrecognized selector sent to instance 0x2828c1740

Any tips where I'm missing something here guys?

Thanks

Best Answer

  • starl1nstarl1n DO ✭✭
    edited December 2018 Accepted Answer

    Ok, after much trial and error, and asking the provider of the SDK I was pointed to set the the Linker flags to -objC **, this has to be done in the Properties of the file, Binding Project > in the Native References file (the one that has the extension **.a)

    after that, rebuild the project and was able to connect to the Label Printer via bluetooth without issues.

    Thanks

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    This is a normal error ,it's not related with binding.

    Can you try to use this library with iOS project(in xcode) to see if error persists ?

  • starl1nstarl1n DOUniversity ✭✭

    Hi @ColeX ,

    That's the thing, using the library in an example in Objective C that the owner provide works

    what I don't know if this typedef is converting properly

    // typedef void (^DzDidOpenedPrinterBlock)(BOOL);
    delegate void DzDidOpenedPrinterBlock(bool data);

    the interesting part is that it give error when it find any printers, if it doesn't I don't get any crash

  • starl1nstarl1n DOUniversity ✭✭

    Also I try to add the following method

    [Export("objectOnIndex:")]
    NSArray ObjectOnIndex(NSObject obj);

    which is the one that says is an invalid selector, but can't see the details of this to know if i'm putting the right data types and so..

    By the way what is an __NSArrayI,? an immutable array? because I can't find a class for this in the Foundation API

  • starl1nstarl1n DOUniversity ✭✭
    edited December 2018 Accepted Answer

    Ok, after much trial and error, and asking the provider of the SDK I was pointed to set the the Linker flags to -objC **, this has to be done in the Properties of the file, Binding Project > in the Native References file (the one that has the extension **.a)

    after that, rebuild the project and was able to connect to the Label Printer via bluetooth without issues.

    Thanks

Sign In or Register to comment.