2014-01-23 56 views
3

我試圖做一個結合了StickNFind在基於Xamarin項目使用。爲Xamarin綁定StickNFind編譯失敗

有問題的類是LeDeviceManager,它繼承了CBCentralManagerDelegate,這是一個抽象類,而UpdateState(m)方法不是綁定的一部分。

下面是這個類的對象 - 標題:

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 

這是結合我拿出,用客觀記號筆沉重的援助:

[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)' hides inherited abstract member MonoTouch.CoreBluetooth.CBCentralManagerDelegate.UpdatedState(MonoTouch.CoreBluetooth.CBCentralManager)」(CS0533)(SNF_Binding)

如何解決這個問題:

+0

綁定協議部分沒有完成這個綁定?我需要同樣的東西,如果你已經做到了,不用重新發明輪子。 –

+0

我確實設法讓它通過了那個錯誤,但是後來我又發現了一些關於SNF SDK中重複名稱的錯誤,我放棄了。我經歷了一大堆與SNF麻煩去了,我不建議他們 - 他們所有的代碼是非常糟糕的,信標行爲無法預測,我永遠無法使他們的工作,他們的支持是非常糟糕。 –

回答

1

你好你可以試試這個呢?

[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