【发布时间】:2016-04-20 04:01:20
【问题描述】:
我已阅读 Xamarin 的文档。
这是我在 Objective-C 中的测试类:
#import "XamarinBundleLib.h"
@implementation XamarinBundleLib
+(NSString *)testBinding{
return @"Hello Binding";
}
@end
很简单,只有一种方法。
这是我的 C# 类:
namespace ResloveName
{
[BaseType (typeof (NSObject))]
public partial interface IXamarinBundleLib {
[Static,Export ("testBinding")]
NSString TestBinding {get;}
}
}
那么这是我的 AppDelegate 代码:
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
string testStr = ResloveName.IXamarinBundleLib.TestBinding.ToString ();
System.Console.WriteLine ("testStr="+testStr);
return true;
}
TestBinding 属性为空。 我一定是哪里出错了,我该如何解决呢?
【问题讨论】:
-
您尝试过 Objective Sharpie 吗? developer.xamarin.com/guides/cross-platform/macios/binding/…
-
尝试使用
string而不是NSString进行绑定。如果这不起作用,很可能是本机库由于某种原因没有链接到可执行文件(构建日志会显示这一点)。 -
我尝试使用字符串而不是 NSString,但这也不对。现在我想我的原生库也可能有问题,我会检查一下。谢谢你的建议。
标签: c# ios objective-c binding xamarin.ios