2

I’m trying to bind an objective-c library with a delegate

@protocol PKTokenFieldDelegate <UITextFieldDelegate>

    -(void)tokenShouldChangeHeight:(CGFloat)height;

@optional
    -(void)tokenFieldDidSelectToken:(PKToken*)token;
    -(void)tokenFieldDidBeginEditing:(PKTokenField*)tokenField;
    -(void)tokenFieldDidEndEditing:(PKTokenField*)tokenField;

@end

Sharpie output based on the walkthrough on xamarin developer site.

// @protocol PKTokenFieldDelegate <UITextFieldDelegate>
[BaseType (typeof (NSObject))]
[Model]
interface PKTokenFieldDelegate : IUITextFieldDelegate
{
    // @required -(void)tokenShouldChangeHeight:(CGFloat)height;
    [Abstract]
    [Export ("tokenShouldChangeHeight:")]
    void TokenShouldChangeHeight (nfloat height);

    // @optional -(void)tokenFieldDidSelectToken:(PKToken *)token;
    [Export ("tokenFieldDidSelectToken:")]
    void TokenFieldDidSelectToken (PKToken token);

    // @optional -(void)tokenFieldDidBeginEditing:(PKTokenField *)tokenField;
    [Export ("tokenFieldDidBeginEditing:")]
    void TokenFieldDidBeginEditing (PKTokenField tokenField);

    // @optional -(void)tokenFieldDidEndEditing:(PKTokenField *)tokenField;
    [Export ("tokenFieldDidEndEditing:")]
    void TokenFieldDidEndEditing (PKTokenField tokenField);
}

This only creates an object that I can inherit from instead of creating an interface. I need to have this as an interface. What am I missing?

Thanks

Erik Rodriguez
  • 145
  • 1
  • 10

1 Answers1

1

I just had to change the [Model] to [Protocol] in order for this to work.

I also ran into a problem when the namespace and class name are the same that you get errors. Which is what got me down the road of changing Protocol to Model in the first place.

Erik Rodriguez
  • 145
  • 1
  • 10