iOS绑定:如何为实现多个委托的类创建绑定?

时间:2013-09-20 23:04:23

标签: ios binding xamarin.ios xamarin

我正在尝试创建一个绑定项目,但我不知道如何绑定下一个实现三个不同委托的接口:

@interface Integration :  NSObject<NSURLConnectionDelegate, SomeControllerDelegate, 
CLLocationManagerDelegate>
{
    id<VendorIntegrationDelegate> delegate;
    Information *Information;
    SomeController * controller;
}

@property(nonatomic,assign) id<VendorIntegrationDelegate> delegate;
@property(nonatomic,strong) Information *Information;
@property(nonatomic,strong) SomeController *controller;

@end

在ApiDefinition.cs中我做了如下绑定,它缺少SomeControllerDelegate和CLLocationManagerDelegate的实现:

[BaseType (typeof (NSUrlConnectionDelegate), Delegates=new string [] { "WeakDelegate" },
Events=new Type [] { typeof (VendorIntegrationDelegate)})]
public partial interface Integration
{
    [Export ("delegate", ArgumentSemantic.Assign), NullAllowed]
    NSObject WeakDelegate { get; set; }

    [Wrap("WeakDelegate")]
    VendorIntegrationDelegate Delegate { get; set; }

    [Export ("Information", ArgumentSemantic.Retain)]
    Information Information { get; set; }

    [Export ("controller", ArgumentSemantic.Retain)]
    SomeController  Controller { get; set; }

}

我在进行此绑定时发现的问题是接口继承了几个类,如何创建此绑定

1 个答案:

答案 0 :(得分:1)

如果问题与SomeControllerDelegate有关,请将其声明为[Model],而不是[BaseType],如下所示:

[Model]
interface SomeControllerDelegate
{
    //...
}

//...

[BaseType (typeof (NSUrlConnectionDelegate), /*...*/]
interface Integration : SomecontrollerDelegate
{
    ...
}