© Jesse Feiler 2019
Jesse FeilerImplementing iOS and macOS Documents with the Files Apphttps://doi.org/10.1007/978-1-4842-4492-0_6

6. Implementing Documents on iOS

Jesse Feiler1 
(1)
Plattsburgh, NY, USA
 
There are three main issues you have to consider when implementing documents on iOS:
  • With the advent of the iOS Files app in iOS 11, users began to have access to the underlying file system in iOS.

  • The basic class for iOS documents is UIDocument, which is designed to be subclassed.

  • UIDocumentBrowserViewController is a view controller designed to implement the user interface of the Files iOS app.

This chapter focuses on the first point: Files.

Using Files and the iOS File System

When the first iPhone was launched, it wasn’t an immediate success. In fact, if you go back and search for news articles, you’ll discover some major complaints about the product. One of the biggest was the absence of connectors (such as USB) to attach other devices to the iPhone in the way that users were accustomed to attaching devices to personal computers.

The fact that the entire iPhone file system was hidden from the user’s view was one of the common complaints. There were reasons for the hidden file system architecture and, over the decade of iPhone use, users, developers, and analysts have come to learn the benefits (and sometimes, drawbacks) of this architecture.

With the advent of iOS 11 in 2017, Apple released its Files app, which approached the issue of file management in a very different way from the architecture that people were accustomed to from the beginning of the personal computer era. In the basic personal computer file architecture, which was built on the traditional Unix file architecture, users managed files and folders, which could be placed almost anywhere on the device. The Files app takes a different approach in that files are accessible from specific areas that are usually related to apps. In other words, instead of thinking of files that can be moved anywhere on a personal computer’s disk, users are now encourage to think of files that can be moved anywhere within an app’s file space (often referred to as a sandbox).

Recognizing that people are not simply using disk space on a personal computer, the Files app incorporates access to cloud storage services that go beyond a personal computer such as iCloud, Dropbox, Box, Google Drive, and OneDrive.

For people who are accustomed to the legacy structure where users can place files where they want to, this can be a relearning experience. Perhaps the most important point to consider is that with the legacy file structure, you place files where you want to place them in relation to your computer’s disks and other storage locations. Using the iOS File System and Files, you place files in either of two general locations:
  • You can place files in the folder for a specific app. A folder can be shared among several related apps. For good examples of this type of sharing, use the built-in Pages, Keynote, or Numbers apps and experiment by saving files to be shared.

  • You can place files in a cloud storage service such as iCloud or Dropbox.

Here are some details about using Files.

Choosing Document Storage Locations

Remember that file storage is primarily determined by the app a file is associated with. Your primary tool for choosing the storage location is by setting it in Settings for an app. For example, in Settings, you can see the various settings for installed apps on your iOS device (Figure 6-1).
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig1_HTML.jpg
Figure 6-1.

Choosing the settings for your apps

Find your app and then choose the storage location, as shown in Figure 6-2. Your choices depend on what you have installed on your iOS device. If you use iCloud (a very common choice), you can choose to store your data there. You can choose to store it on a local device or you can use Dropbox, Box, or another service.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig2_HTML.jpg
Figure 6-2.

Choosing a document storage location

Browsing Documents

When you use Files, you can choose to browse files in a specific location (this, of course, depends on what you have chosen for locations and the files that you have). It’s important to understand the browsing data that Files shows you, so the following images show you what you might see.

If you have decided to use your iPad for storage, you might see the browse results shown in Figure 6-3 when you choose the On My iPad location.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig3_HTML.jpg
Figure 6-3.

Browsing the On My iPad files

If you use iCloud Drive, you may see a browse window such as the one shown in Figure 6-4.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig4_HTML.jpg
Figure 6-4.

Browsing documents and folders on iCloud Drive

Note that when you browse, the locations are at the left of the window. When you select a specific file or folder, you will see its container indicated either in Locations at the left or at the top of the right-hand list, as in Figure 6-5.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig5_HTML.jpg
Figure 6-5.

Folder names at the top of the right-hand pane

Looking at Recent Documents

Using the tabs at the bottom of the window, you can switch between recent files and folders and ones that you want to browse. Figure 6-6 shows recent files and folders.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig6_HTML.jpg
Figure 6-6.

Recent files and folders

If some of your documents have not yet been downloaded from a remote server, you will see the cloud icon shown in Figure 6-7, indicating that they are waiting to be downloaded. If you tap a specific file, you can speed up its downloading process.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig7_HTML.jpg
Figure 6-7.

Downloading files

Note that in addition to indicating if a file needs to be downloaded, you can see its location. For example, in Figure 6-7, in the lower right, you can see a document that is marked as On My iPad rather than iCloud Drive.

Tip

Get used to working with Files and using the file location information and download status. Because there is often a time lag as a download is scheduled and processed, you will save yourself time if you know what files are where so that you don’t try to debug issues that are merely timing issues.

Viewing Files and Folders for an App

When you look at apps on an iOS device, you can tap and hold an app icon to see the files and folders that may belong to it, as shown in Figure 6-8.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig8_HTML.jpg
Figure 6-8.

Tap and hold an app icon to see its files

If necessary, a Show More button will appear at the top right, as you can see in Figure 6-8. When you use Show More, a companion Show Less button appears, as you can see in Figure 6-9.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig9_HTML.jpg
Figure 6-9.

The Show Less option

When you look at the apps in Files (Figure 6-7), you will see a list of the files and folders, as shown in Figure 6-10.
../images/465467_1_En_6_Chapter/465467_1_En_6_Fig10_HTML.jpg
Figure 6-10.

A list of all files and folders for an app

Summary

Use Settings to control where you store the files and folders for an app, and use Files to browse files and folders as well as recents.

Remember that you control where the files and folders are placed not by selecting locations on your personal computer but by selecting locations on the device you’re using or on a cloud storage function such as iCloud or Dropbox.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.124.252