Chapter 10. Working with Files and File Types
At the moment, the iOS app can work with the text content of note documents, but doesn’t really know anything about attachments that might have been added through the OS X app.
In this chapter, we’ll add support for working with attachments to the iOS app, as well as make its handling of note documents more robust. We’ll do this by adding—you guessed it—more user interface to:
-
display any attachments.
-
handle conflict resolution, for when a file is synced from multiple devices.
-
add Quick Look support, to display a thumbnail preview of attachments.
Setting Up the Interface for Attachments
First, we’ll update the interface for the document view controller to support showing the list of attachments. This will involve reworking everything, as well as some reasonably complex constraints, so it’s easier to start from scratch.
-
Open Main.storyboard.
-
Delete the text view from the document view controller’s interface. We’ll be reconstructing the interface, with room for the attachments to be displayed, so it’s easier to remove everything than it is to rearrange.
-
It’ll be easier to do this without the top bar in the way, so select the document view controller, and in the Simulated Metrics section of the Inspector, change Top Bar from Inferred to None (Figure 10-1).
-
Drag a
UIScrollView ...
Get Learning Swift now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.