我有一个在 AR 中提供协作的应用程序,我正在关注如何ARSession.CollaborationData
使用MultipeerConnectivity
.
看来,在 iOS 14 中,这不再可能。当我尝试取消归档时收到以下错误:
“ARCollaborationData”类不允许安全编码。它必须从 supportSecureCoding 返回 YES。
我或多或少地使用了文档中给出的确切代码,它在 iOS 13 上完美运行。现在,对于 iOS 14,我不知道如何解决这个问题。我尝试过发送它并requiringSecureCoding: false
尝试创建一个NSKeyedUnarchiver
也requiresSecureCoding
设置为 false 的。据我所知,我无法更改 for 的实现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)
以前有没有其他人遇到过这个问题?难道这是一个错误,我只需要报告它并等待吗?无论哪种方式,提前感谢任何提示或提示:) 非常感谢他们!
最好的问候, 比约恩