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 をネイティブ ライブラリに渡すことに関係しているのではないかと思います。
何か案は?
ありがとう