我有一個第三方的OBJ-C庫(我寫的MonoTouch綁定),其通過內UIImagePickerControllerDelegate
的FinishedPickingMedia
功能(ZBar iPhone SDK for those interested)編組一個NSObject的已內MonoTouch的派生類的實例
NSDictionary
參數返回數據
我綁定了我希望存儲在本字典中的實例的類(ZBarSymbol
)。
如我所料,MonoTouch的運行不可能通過所有這些收集情況檢查編組時,我的MonoTouch的代碼只看到了NSObject
實例在字典中(如果這個假設是錯誤的,它應該是一個ZBarSymbol
實例,有人請讓我知道)。
我試圖手動元帥NSObject
建成一ZBarSymbol
使用下面的代碼:服用
public override void FinishedPickingMedia (UIImagePickerController picker, NSDictionary info)
{
var result = info[ZBarSDK.BarcodeResultsKey];
var symbol = result as ZBarSymbol;
if (symbol != null)
{
// This never works obviously.
}
else
{
symbol = new ZBarSymbol(result.Handle);
Console.WriteLine("Data = " + symbol.Data);
}
}
的ZBarSymbol的構造函數指針正常工作。然而試圖訪問任何成員(例如Data
屬性導致以下異常:
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
Name: NSInvalidArgumentException
Reason: -[ZBarSymbolSet data]: unrecognized selector sent to instance 0x8d2960
at ZBar.ZBarSymbol.get_Data() [0x00000] in <filename unknown>:0
at ZBarMonoTouchTest.ZBarMonoTouchTestViewController+BarcodeReaderCallback.FinishedPickingMedia (MonoTouch.UIKit.UIImagePickerController picker, MonoTouch.Foundation.NSDictionary info) [0x00197] in /Users/tyson/Projects/ZBarMonoTouchTest/ZBarMonoTouchTestViewController.cs:112
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at ZBarMonoTouchTest.Application.Main (System.String[] args) [0x00000] in /Users/tyson/Projects/ZBarMonoTouchTest/Main.cs:17
所以是有可能在應用程序代碼中在名帥這些類如果是這樣,怎麼甚至更好,如果有人能?告訴我如何設置綁定,以便自動發生(但我不確定這是可能的)。