我对以下代码中的错误有疑问。
错误: 无法将类型“ AnyClass”(也称为“ AnyObject.Type”)的值转换为 预期的参数类型“ [AnyClass]”(又名“数组”)
代码:
func receivedData( data: Data, from peer: MCPeerID) {
if let unarchived = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: ARWorldMap.classForKeyedArchiver()!, from: data), // error is here
let worldMap = unarchived as? ARWorldMap {
showAlert()
// Run the session with the received world map.
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .horizontal
configuration.initialWorldMap = worldMap
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
// Remember who provided the map for showing UI feedback.
mapProvider = peer
}
else
if let unarchived = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: ARAnchor.classForKeyedUnarchiver()!, from: data), // and here
let anchor = unarchived as? ARAnchor {
sceneView.session.add(anchor: anchor)
let node = loadObject()
node.position = SCNVector3.positionFromTransform(anchor.transform)
sceneView.scene.rootNode.addChildNode(node)
}
else {
print("unknown data recieved from \(peer)")
}
}