0

我正在尝试同步使用 InputStream/OutputStream(如普通 IOStreams)以读取/写入特定的蓝牙设备。我知道这样做是可能的,因为我们有一些可以与我们的小工具一起使用的 Objective-C 代码 - 但是我们正在使用第三方 c# 库并且需要让它在 c# 中工作。

我已经做到了这一点:

string protocol = <protocol string>
// Attempt to connect to device...
EASession _session = new EASession (myEAAccessory, protocol);
inStream = _session.InputStream;
outStream = _session.OutputStream;

我可以看到 _session 已在内存中分配 - Xamarin 向我展示它现在具有非空指针和数据类型 - 但是 InputStream 和 OutputStream 都是空的(因此我无法打开它们,因为这会引发 nullref 异常)。

如何让 OutputStream 和 InputStream 不为空?

(我正在尝试阅读很多苹果文档,但他们的代码示例都在 Objective-C 中,我只是勉强理解......而且 Objective-C“内存管理”语句不适用?)

编辑另外,我检查了 myEAAcessory 不为空,并且返回 true:

myEAAcessory .ProtocolStrings.Contains (protocol);
4

1 回答 1

1

您需要在 Info.plist 中列出要使用的外部附件。

苹果网站上有一些关于此的文档:http: //developer.apple.com/library/ios/#featuredarticles/ExternalAccessoryPT/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009502

这是如何在 Info.plist 中设置此值的屏幕截图:http: //screencast.com/t/AYmOWjf8wkL

(这是从这里:https ://bugzilla.xamarin.com/show_bug.cgi?id=1635#c1 )

于 2013-11-20T23:46:41.760 回答