1

Xamarin で使用できるように、Good Dynamics のバインドを作成しようとしています。最終的にビルドできるようになりましたが、グッドダイナミクスを初期化しようとすると、次のエラーが発生します。

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsisenter code heretencyException Reason: AppDelegate does not implement UIApplicationDelegate. Check that the class is correct and it conforms to this protocol.
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr (intptr,intptr,intptr)
  at GDBinding.GDiOS.InitializeWithClassConformingToUIApplicationDelegate (MonoTouch.ObjCRuntime.Class applicationDelegate) [0x00000] in <filename unknown>:0
  at GDTest.Application.Main (System.String[] args) [0x00006] in /Users/gareth/GDTest/GDTest/Main.cs:20

Main.cs の 20 行目は

GDiOS.InitializeWithClassConformingToUIApplicationDelegate(new MonoTouch.ObjCRuntime.Class(typeof(AppDelegate)));

AppDelegate で UIApplicationDelegate を拡張し、同じ結果で UIApplicationDelegate の基本型を持つ GDiOSDelegate も拡張してみました。

namespace GDBinding
{
    [BaseType (typeof (NSObject), Delegates = new string[] {"WeakDelegate"}, Events = new Type[] {typeof(GDiOSDelegate)})]
    interface GDiOS {

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

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

    //+ (void)initializeWithClassNameConformingToUIApplicationDelegate:(NSString*)applicationDelegate;
    [Static, Export ("initializeWithClassNameConformingToUIApplicationDelegate:")]
    void InitializeWithClassNameConformingToUIApplicationDelegate (string applicationDelegate);

    //+ (void)initialiseWithClassConformingToUIApplicationDelegate:(Class)applicationDelegate;
    [Static, Export ("initializeWithClassConformingToUIApplicationDelegate:")]
    void InitializeWithClassConformingToUIApplicationDelegate (Class applicationDelegate);

    //+ (BOOL)isInitialized;
    [Static, Export ("isInitialized")]
    bool IsInitialized();

    //+ (GDiOS*)sharedInstance;
    [Static, Export ("sharedInstance")]
    GDiOS SharedInstance();

    //- (UIWindow*)getWindow;
    [Export ("getWindow")]
    UIWindow GetWindow();

}

[BaseType(typeof(UIApplicationDelegate))]
interface GDiOSDelegate {
    [Abstract, Export("handleEvent:")]
    void HandleEvent(GDAppEvent anEvent);
}

[BaseType(typeof(NSObject))]
interface GDAppEvent {
    [Export("message")]
    string Message { get; set; }

    [Export("code")]
    GDAppResultCode Code { get; set; }

    [Export("type")]
    GDAppEventType EventType { get; set; }
    }
}

コードはhttps://github.com/garethrhughes/GDTestにあります

この問題は、monotouch AppDelegate をネイティブ ライブラリに渡すことに関係しているのではないかと思います。

何か案は?

ありがとう

4

1 に答える 1

2

これが古いスレッドであることは知っていますが、同僚と私は、GOOD の SDK (v1.8.x) の新しいバージョンを使用してこのプロセスを実行し、機能させることができました。サンプル プロジェクトへのリンクを含む記事をここに投稿しました。

于 2014-10-10T16:34:26.430 に答える