简体   繁体   English

第三方库中的MonoTouch绑定通知

[英]MonoTouch binding notifications in 3rd party library

I am working to create bindings for IDTech CC swipers. 我正在为IDTech CC swipers创建绑定。 I have been banging my head against this for a while. 我一直在反对这个问题。 I am stuck on how to subscribe to events that are raised by the 3rd party library. 我被困在如何订阅第三方库引发的事件。 Specifically, I need to know when a card swipe has occured. 具体来说,我需要知道卡片刷卡何时发生。

//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;

The documentation says this should work: 文档说这应该工作:

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

It doesn't compile. 它不编译。

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'

Any thoughts or help would be greatly appreciated! 任何想法或帮助将不胜感激!

Try: 尝试:

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

The second parameter tells inside which library to look for the field. 第二个参数告诉在哪个库中查找该字段。 Without one the generator presume you'll have a constant ready for it. 没有一个发电机假设你将有一个恒定的准备。

Now since you'll be linking the 3rd party static (.a) library it will become part of the final executable. 现在,因为您将链接第三方静态 (.a)库,它将成为最终可执行文件的一部分。 That's why __Internal must be used as the library name (it means looks inside the main executable). 这就是__Internal必须用作库名的原因(它意味着查看主可执行文件内部)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM