gpt4 book ai didi

xamarin.ios - 为 Xamarin 绑定(bind) StickNFind 编译失败

转载 作者:行者123 更新时间:2023-12-02 03:39:05 24 4
gpt4 key购买 nike

我正在尝试为 StickNFind 创建一个绑定(bind),以便在基于 Xamarin 的项目中使用。

有问题的类是LeDeviceManager,它继承了CBCentralManagerDelegate,这是一个抽象类,UpdateState(m)方法不是其中的一部分的绑定(bind)。

这是这个类的 Obj-C header :

interface LeDeviceManager : NSObject <CBCentralManagerDelegate>

@property (nonatomic,strong) NSMutableArray *devList;
@property (nonatomic) CBCentralManager *btmgr;
@property (nonatomic,strong) id <LeDeviceManagerDelegate> delegate;

- (id) initWithSupportedDevices: (NSArray *) devCls delegate: (id <LeDeviceManagerDelegate>) del;
- (void) startScan;
- (void) stopScan;

@end

这是我在 Objective Sharpie 的大力协助下提出的绑定(bind):

    [Model, BaseType (typeof(CBCentralManagerDelegate))]
public partial interface LeDeviceManager
{
[Export ("devList", ArgumentSemantic.Retain)]
NSMutableArray DevList { get; set; }

[Export ("btmgr")]
CBCentralManager Btmgr { get; set; }

[Export ("delegate", ArgumentSemantic.Retain)]
LeDeviceManagerDelegate Delegate { get; set; }

[Export ("initWithSupportedDevices:delegate:")]
IntPtr Constructor (NSObject[] devCls, LeDeviceManagerDelegate del);

[Export ("startScan")]
void StartScan ();

[Export ("stopScan")]
void StopScan ();

[Export ("UpdatedState")]
[New] // Added as suggested by another SO post, also tried [Abstract]
void UpdatedState(CBCentralManager mgr);
}

我得到这个错误: 错误 CS0533:StickNFind.LeDeviceManager.UpdatedState(MonoTouch.CoreBluetooth.CBCentralManager)' 隐藏了继承的抽象成员MonoTouch.CoreBluetooth.CBCentralManagerDelegate.UpdatedState(MonoTouch.CoreBluetooth.CBCentralManager)' (CS0533) (SNF_Binding)

我该如何解决这个问题:

最佳答案

你好,你能试试这个吗?

[Protocol] // Added Protocol attribute
[Model]
[BaseType (typeof(NSObject))] //Changed BaseType to NSObject
public partial interface LeDeviceManager : ICBCentralManagerDelegate
{
[Export ("devList", ArgumentSemantic.Retain)]
NSMutableArray DevList { get; set; }

[Export ("btmgr")]
CBCentralManager Btmgr { get; set; }

[Export ("delegate", ArgumentSemantic.Retain)]
LeDeviceManagerDelegate Delegate { get; set; }

[Export ("initWithSupportedDevices:delegate:")]
IntPtr Constructor (NSObject[] devCls, LeDeviceManagerDelegate del);

[Export ("startScan")]
void StartScan ();

[Export ("stopScan")]
void StopScan ();

[Export ("updatedState")] [New] // Notice I changed UpdatedState to updatedState lowercase u
void UpdatedState(CBCentralManager mgr);
}

我强烈推荐阅读 this doc 的绑定(bind)协议(protocol)部分

关于xamarin.ios - 为 Xamarin 绑定(bind) StickNFind 编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21321765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com