这是我最后的question有关绑定的Objective-C库xamarin项目跟进。 所以我想,我将创建API定义我自己,但我无法弄清楚如何改写的Objective-C委托给C#委托/事件。我已经了解到,objective-c委托与C#委托并不相同,但更像C#事件。Xamarin结合的Objective-C库,C#委托和事件
这是目标c委托定义(来自头文件):
@protocol LineaDelegate
@optional
-(void)connectionState:(int)state;
@end
这是目标c类定义(从标题文件):
@interface Linea : NSObject
-(void)connect;
@end
的连接方法在后台工作,并通过connectionState委托通知调用者连接成功。
现在,我该如何正确地绑定API?这是我的ApiDefinition.cs到目前为止:
[BaseType(typeof(NSObject))]
interface Linea{
[Export ("isPresent")]
bool IsPresent();
//the delegate that will be notified of Linea events
[Export("addDelegate:")]
void AddDelegate (NSObject newDelegate);
[Export("connect")]
void Connect();
}
如何将objective-c委托转换为Xamarin studio和C#中有用的东西?现在
太谢谢你了!我试图找到这样的东西。 –