微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

类“ ARCollaborationData”不允许安全编码

如何解决类“ ARCollaborationData”不允许安全编码

我有一个应用程序可在AR中提供协作,并且我一直在关注如何使用ARSession.CollaborationData发送MultipeerConnectivity的文档。

https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration/3152987-iscollaborationenabled

看来,在iOS 14中,这不再可能。尝试取消存档时收到以下错误

'ARCollaborationData'类不允许安全编码。它必须返回 来自supportSecureCoding,是。

我或多或少地使用了文档中给出的确切代码,并且它在iOS 13上可以完美运行。现在,在iOS 14上,我不确定如何解决此问题。我尝试使用requiringSecureCoding: false发送它,并尝试创建一个NSKeyedUnarchiver也设置为false的requiresSecureCoding。据我所知,我无法为NSSecureCoding更改ARSession.CollaborationData的实现(据说应该仍然存在)。

这是发送数据的代码

guard let encodedData = try? NSKeyedArchiver.archivedData(
    withRootObject: data,requiringSecureCoding: true
)
else { fatalError("Unexpectedly Failed to encode collaboration data.") }
// Use reliable mode if the data is critical,and unreliable mode if the data is optional.
let dataIsCritical = data.priority == .critical
try session.send(
    encodedData,toPeers: session.connectedPeers,with: dataIsCritical ? .reliable : .unreliable
)

然后我通过调用函数来解码所有内容

NSKeyedUnarchiver.unarchivedobject(ofClass: ARSession.CollaborationData.self,from: data)

其他人以前有这个问题吗?难道这是一个错误,我只需要报告它并等待?无论哪种方式,在此先感谢您的提示或技巧:)非常感谢!

最好的问候, 比约恩

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。