3

我正在为 IDTech CC swipers 创建绑定。一段时间以来,我一直在努力解决这个问题。我被困在如何订阅 3rd 方库引发的事件上。具体来说,我需要知道刷卡发生的时间。

//Notification identifiers used with NSNotificationCenter
//physical attachment related
extern NSString * const uniMagAttachmentNotification;
extern NSString * const uniMagDetachmentNotification;
//connection related
extern NSString * const uniMagInsufficientPowerNotification;
extern NSString * const uniMagPoweringNotification;
extern NSString * const uniMagTimeoutNotification;
extern NSString * const uniMagDidConnectNotification;
extern NSString * const uniMagDidDisconnectNotification;
//swipe related
extern NSString * const uniMagSwipeNotification;
extern NSString * const uniMagTimeoutSwipeNotification;
extern NSString * const uniMagDataProcessingNotification;
extern NSString * const uniMagInvalidSwipeNotification;
extern NSString * const uniMagDidReceiveDataNotification;
//command related
extern NSString * const uniMagCmdSendingNotification;
extern NSString * const uniMagCommandTimeoutNotification;
extern NSString * const uniMagDidReceiveCmdNotification;
//misc
extern NSString * const uniMagSystemMessageNotification;

文档说这应该有效:

    [Notification]
    [Field ("uniMagAttachmentNotification")]
    NSString uniMagAttachmentNotification { get; }

它不编译。

obj/Debug/ios/magTechBinding/uniMag.g.cs(637,95): error CS0117: `MonoTouch.Constants' does not contain a definition for `magTechBindingLibrary'
obj/Debug/ios/magTechBinding/uniMag.g.cs(637,77): error CS1502: The best overloaded method match for `MonoTouch.ObjCRuntime.Dlfcn.dlopen(string, int)' has some invalid arguments
obj/Debug/ios/magTechBinding/uniMag.g.cs(637,77): error CS1503: Argument `#1' cannot convert `object' expression to type `string'

任何想法或帮助将不胜感激!

4

1 回答 1

5

尝试:

[Field ("uniMagAttachmentNotification", "__Internal")]

第二个参数告诉在哪个库中查找该字段。如果没有一个,生成器会假定您已经为它做好了准备。

现在,由于您将链接第 3 方静态(.a) 库,它将成为最终可执行文件的一部分。这就是为什么__Internal必须用作库名称的原因(这意味着在主可执行文件中查找)。

于 2013-01-22T20:50:01.630 回答