I try to upload and unarchive World Map from firebase (which was previously serialized and loaded there), but I catch an error. Could you help me with my code. What am I doing wrong? Thank you.
@IBAction func downloadButtonAction(_ sender: Any) {
//1. link on Firebase
let storageRef = Storage.storage().reference(withPath: "folder/1.bmarwp")
//2. Get data from firebase
storageRef.getData(maxSize: 10 * 1024) { (data, error) in
if let error = error {
print("Got an error fetching data: \(error.localizedDescription)")
return
}
if let data = data {
//3. Unarchive object
//I GOT error here: value for key 'root' was of unexpected class 'NSDictionary'. Allowed classes are '{(ARWorldMap
guard let downloadedMap = try! NSKeyedUnarchiver.unarchivedObject(ofClasses: [ARWorldMap.classForKeyedUnarchiver()], from: data) as? ARWorldMap
else { fatalError("No ARWorldMap in archive.")}
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal]
if let downloadedMap = downloadedMap {
configuration.initialWorldMap = downloadedMap
self.showAlert(message: "Map loaded from server")
} else {}
let options: ARSession.RunOptions = [.resetTracking, .removeExistingAnchors]
self.sceneView.debugOptions = [.showFeaturePoints]
self.sceneView.session.run(configuration, options: options)
return
}
}