Objective Sharpie 有时会将 I 添加到 @protocols

Objective Sharpie sometimes adds I to @protocols

我正在尝试绑定一个库,我遇到了这个问题:

// @interface PTPusher : NSObject <PTPusherConnectionDelegate, PTPusherEventBindings>
[BaseType(typeof(NSObject))]
interface PTPusher : IPTPusherConnectionDelegate, IPTPusherEventBindings

无法找到 IPTPusherConnectionDelegateIPTPusherEventBindings,但它们未更改的名称确实存在:

// @protocol PTPusherConnectionDelegate <NSObject>
[Protocol, Model]
[BaseType(typeof(NSObject))]
interface PTPusherConnectionDelegate

为什么 Objective Sharpie 在继承接口列表中添加 I,而不是在接口名称本身中添加?

我应该更改什么来解决这个问题?我是将 I 添加到接口名称还是从继承的接口列表中删除 I?或者我可以在不改变这些的情况下解决这个问题,只是通过添加或删除那些 classes/interfaces?

的属性

Starting with MonoTouch 7.0 a new and improved protocol binding functionality has been incorporated. Any definition that contains the [Protocol] attribute will actually generate three supporting classes that vastly improve the way that you consume protocols:

// Full method implementation, contains all methods
class MyProtocol : IMyProtocol {
    public void Say (string msg);
    public void Listen (string msg);
}

// Interface that contains only the required methods
interface IMyProtocol: INativeObject, IDisposable {
    [Export ("say:”)]
    void Say (string msg);
}

// Extension methods
static class IMyProtocol_Extensions {
    public static void Optional (this IMyProtocol this, string msg);
    }
}

此外,

If you want to use the protocol definitions in your API, you will need to write skeleton empty interfaces in your API definition. If you want to use the MyProtocol in an API, you would need to do this:

[BaseType (typeof (NSObject))]
[Model, Protocol]
interface MyProtocol {
    // Use [Abstract] when the method is defined in the @required section
    // of the protocol definition in Objective-C
    [Abstract]
    [Export ("say:")]
    void Say (string msg);

    [Export ("listen")]
    void Listen ();
}

interface IMyProtocol {}

[BaseType (typeof(NSObject))]
interface MyTool {
    [Export ("getProtocol")]
    IMyProtocol GetProtocol ();
}

来源:https://developer.xamarin.com/guides/cross-platform/macios/binding/binding-types-reference/#Protocols