2012-10-26 26 views
2

我對Applifier API以下綁定:MonoTouch的結合未能接受委託模型

namespace MonoTouch.Applifier { 

[BaseType (typeof (NSObject))] 
interface Applifier { 
    [Export ("initWithApplifierID:withWindow:supportedOrientations:"), Static] 
    Applifier InitWithApplifierId (string applifierId, UIWindow withWindow, 
     UIDeviceOrientation firstOrientation, IntPtr orientationsPtr); 

    [Export ("initWithApplifierID:withWindow:delegate:usingBanners:usingInterstitials:usingFeaturedGames:supportedOrientations:"), Static] 
    Applifier InitWithApplifierId (string applifierId, UIWindow withWindow, 
     ApplifierGameDelegate gameDelegate, bool usingBanners, bool usingInterstitials, 
     bool usingFeaturedGames, UIDeviceOrientation firstOrientation, IntPtr orientationsPtr); 

    [Export ("sharedInstance"), Static] 
    Applifier SharedInstance { get; } 

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

    [Export ("gameDelegate", ArgumentSemantic.Retain)] 
    NSObject WeakDelegate { get; set; } 

    [Export ("prepareFeaturedGames")] 
    void PrepareFeaturedGames(); 

    [Export ("showFeaturedGames")] 
    void ShowFeaturedGames(); 

    [Export ("showBannerAt:")] 
    void ShowBannerAt (PointF position); 
} 

[BaseType (typeof (NSObject))] 
[Model] 
interface ApplifierGameDelegate { 
    [Export("applifierInterstitialReady"), Abstract] 
    void InterstitialReady(); 

    [Export("applifierFeaturedGamesReady"), Abstract] 
    void FeaturedGamesReady(); 

    [Export("applifierBannerReady")] 
    void BannerReady(); 

    [Export("applifierAnimatedReady")] 
    void AnimatedReady(); 

    [Export("applifierCustomInterstitialReady")] 
    void CustomInterstitialReady(); 

    [Export("pauseGame")] 
    void PauseGame(); 

    [Export("resumeGame")] 
    void ResultGame(); 
} 
} 

有兩種方法在我的額外C#文件,使調用這些初始化方法更容易一些。我不認爲他們在這裏是相關的,但如果需要的話,我可以包括他們。

這裏的「gameDelegate」的對象 - 聲明:

@property (nonatomic, retain) id<ApplifierGameDelegate> gameDelegate; 

而且ApplifierGameDelegate的協議定義:

@protocol ApplifierGameDelegate <NSObject> 
- (void)applifierInterstitialReady; 
- (void)applifierFeaturedGamesReady; 
@optional 
- (void)applifierBannerReady; 
- (void)applifierAnimatedReady; 
- (void)applifierCustomInterstitialReady; 
- (void)pauseGame; 
- (void)resumeGame; 
@end 

這裏的問題是,無論我怎麼努力,我可以」 t在我的monotouch項目中獲取我的委託實現的方法以從Applifier獲取回調。一些注意事項:

我有以下的applifier教程,做工作(測試情況是,當所示的特色遊戲,在「pauseGame」方法被調用的代表)

在Xcode一個非常簡單的示例應用程序
  • 我注意到,如果我指定任何對象WeakDelegate,沒有什麼抱怨,這驚訝的挫折感了我。例如,沒有錯誤或警告:Applifier.SharedInstance.WeakDelegate = new NSString(「Foo」);
  • 我可以獲取從共享實例委託並調用該方法自己,它被調用。例如:Applifier.SharedInstance.Delegate.PauseGame(); - 這也是如此我是否我的委託實例分配給WeakDelegate,代表,或通過接受委託的參數之一init方法。

我只有現在的結論是,這似乎是兩件事情是真的:

  • 我就可以通過綁定指定任何對象gameDelegate,並沒有什麼抱怨
  • 一些地方沒有認識到我的ApplifierGameDelegate接口與AppliferGameDelegate協議匹配。

我注意到唯一的其他奇怪的是,在所有其他例子綁定我周圍戳在MonoTouch中,綁定Git項目,我還沒有看到使用保留財產上的任何人代表財產。

我MonoTouch的,綁定的叉可以在https://github.com/threerings/monotouch-bindings找到。目前的頭是一個黑客一起變通方法,得到什麼,我們需要做的,但我仍想結束了一個完整的正確的綁定(只需要委託從C#地工作)。原來綁定我在寫關於這個問題,可以在提交fdcff4662a36ac42fbe135c098ff7f71cbdf205d觀看。

+0

你能提供頭?如果你想給我發電子郵件dalexsoto在g郵件,所以我可以檢查您的綁定 – dalexsoto

+0

我suscribed到Applifier但我的帳戶仍處於審覈... – dalexsoto

+0

你需要兩個聲明旁邊有什麼? – roguenet

回答

0

我寫了基於你的綁定,請檢查該綁定爲你工作,我沒有測試過,因爲我沒有一個ApplifierID

https://github.com/dalexsoto/AlexTouch.Applifier

我添加事件,委託類的更容易的使用和綁定大部分的API。

希望這有助於

亞歷

+0

有機會嘗試了這一點。不幸的是,它和我寫的綁定有相同的結果。代表被完全以相同的方式忽略。 – roguenet

+0

奇怪的舉行我有一個線索 – dalexsoto