ZBarの MonoTouch バインディングが動作していますが、NSDictionary のキーとして使用するために Obj-C ライブラリが定義する定数 NSString を公開する際に問題があります。
ZBarReaderController.h 内:
extern NSString* const ZBarReaderControllerResults;
ここに記載されているように、実際の MonoTouch バインディングを介して最初に試しました。
[Static]
interface ZBarSDK
{
[Field ("ZBarReaderControllerResults")]
NSString BarcodeResultsKey { get; }
}
これを含むプロジェクトをビルドしようとすると、btouch から次のエラーが発生しました。
未処理の例外: System.ArgumentOutOfRangeException: 引数が範囲外です。
パラメータ名:
System.String.Substring の startIndex (Int32 startIndex) [0x00000] in :0
at Generator.Generate (System.Type type) [0x00000] in :0
at Generator.Go () [0x00000] in :0
at BindingTouch .Main (System.String[] args) [0x00000] in :0
[エラー] 致命的な未処理の例外: System.ArgumentOutOfRangeException: 引数が範囲外です。
パラメータ名: startIndex
at System.String.Substring (Int32 startIndex) [0x00000] in :0
at Generator.Generate (System.Type type) [0x00000] in :0
at Generator.Go () [0x00000] in :0
BindingTouch.Main (System.String [] args) [0x00000] で:0
次に、 this other SO answerで提案されているように、手動でコードを呼び出そうとしました。
public static NSString BarcodeResultsKey
{
get
{
var libHandle = Dlfcn.dlopen("libzbar.a",0);
// I also tried this with "__Internal", rather than "libzbar.a"
return Dlfcn.GetStringConstant(libHandle, "ZBarReaderControllerResults");
}
}
正常にビルドおよび実行されますが、空の文字列が返されるだけです ( Dlfcn.GetStringConstantドキュメントと同様に、リンクに失敗した場合に実行されます)。
それで、他の誰かがサードパーティの Obj-C ライブラリから const 文字列にアクセスしましたか?