所以这是我的问题:
我的objc静态库中定义了一些协议,如下所示:
@protocol IBar;
@protocol IFoo <NSObject>
@property(nonatomic, strong) NSArray *bars;
@property(nonatomic, strong) id <IBar> currentBar;
@end
他们像这样绑定到Xamarin项目(我在这里使用骨架空接口IIBar)
// @protocol IBar <NSObject>
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface IBar
{
// @required @property (nonatomic, strong) NSString * name;
[Export ("name", ArgumentSemantic.Strong)]
string Name { get; set; }
}
interface IIBar {}
// @protocol IFoo <NSObject>
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface IFoo
{
// @required @property (nonatomic, strong) NSArray * bars;
[Export ("bars", ArgumentSemantic.Strong)]
IIBar[] Bars { get; set; }
// @required @property (nonatomic, strong) id<IBar> currentBar;
[Export ("currentBar", ArgumentSemantic.Strong)]
IIBar CurrentBar { get; set; }
}
这些协议的实施
public class Foo : NSObject, IIFoo
{
//...
}
public class Bar : NSObject, IIBar
{
//...
}
所有内容编译都很好并且在模拟器上工作没有任何问题,但是当我尝试在设备上部署它时,我得到:
MTOUCHTASK:错误MT4111:注册商无法为类型
Binding.IIBar[]' in method
XTestApp.Foo.get_Bars`构建签名。 任务“MTouchTask”执行 - 失败
感谢您的回复
答案 0 :(得分:2)
这看起来像Xamarin.iOS中的一个问题,协议数组无法正常工作。
解决方法是绑定为NSObject[]
或NSArray
。
我建议提交一个关于它的错误,以便修复它(http://bugzilla.xamarin.com)。