Archiving World Map Data for Persistence or Sharing
Serialize and deserialize world map objects for file storage or network transmission.
ARWorldMap conforms to the
NSSecureCoding protocol, so you can convert a world map to or from a binary data representation using the
To send an
ARWorldMap to another device, creating a shared frame of reference for multiuser AR experiences:
On one device, use
NSKeyedArchiver as in Listing 1 to convert the world map to a data object. (You don't need to write the data to a file to send it over the network.)
Use the networking technology of your choice to send the resulting data to another device. (For example, in a MultipeerConnectivity session, call
send(_:toPeers:with:) to send data, and implement
MCSessionDelegate methods on the other device to receive data.)
On the receiving device, use
NSKeyedUnarchiver as in Listing 2 to instantiate an
ARWorldMap from the data.