Skip to main content
Language

Deserialization

Restoring a settings file#

To restore an editor instance to a previous state, we load the saved instance as serialized settings from our main bundle and wrap it in a Data object. It would, of course, also be possible to make a request and load these settings from a remote URL (compare Open Photo from Remote URL).

The deserialize method of the Deserializer class takes those serialized settings as an argument and returns a result set that exposes a PhotoEditModel instance. This photoEditModel is then used to initialize a new PhotoEditViewController instance alongside some photo to which the edits will be applied.

Note that if you are unsure whether the aspect ratio of the photo that the serialized settings are applied to match the photo that they are derived from, you should pass the photo's dimensions explicitly to the deserializer. This ensures that all dimensions and positions are matched as expected.