I. Saving and Sharing Data: Concepts, Terminology, and Options
1. Using Documents
People are used to word processing and spreadsheet documents, but these formats have not always been easy to implement with iOS and macOS. The key feature of documents is that they are visible to users on their device; once visible, users can share those documents, save them, name and rename them, and store them in folders.
By contrast, other types of data storage such as databases and macOS or iOS formats such as property lists let users store and use data in formats that are not visible to the user.
The terms “file” and “document” are often used interchangeably, but they are not the same. This chapter provides the basic definitions and distinctions that are used throughout this book and the Apple (and other) software.
2. Looking Inside Documents
Documents have a format that organizes the data contained in the document such as:
• Standard File Formats (graphics and text) These document formats are can be shared with other apps on other devices so that you can read and write documents created or edited on Microsoft Word, Numbers, or other apps.
• Custom document formats. You can create formats that your apps can read and write; other apps may not be able to read and write them.
• Working with Composite Documents (file managers). Documents can consist of several file formats such text (perhaps a .doc or .docx file) as well as graphics (.jpeg or .png).
3. Matching a Document to a Document Format
The key to using documents on any devices is matching the document format to the physical document description. Originally, this was done simply with file extensions such as .txt or .GIF but as computers and formats have become more complex, those tools are not sufficient.
This chapter provides the key technologies used to match documents and formats on iOS and macOS:
• Document identifiers
• Document types
• Document protocol conformance (mixing and matching formats)
II. Implementing Documents on iOS and macOS
4. Securing and Protecting Data
As soon as you start thinking about saving data, you should be thinking about the security of that data. Every step of the process from deciding what data to store and what rules to implement for safeguarding that data needs to be considered. This chapter focuses on those issues.
• Security and Privacy (access control)
• Security and Protection (managing changes to data)
• Encryption of Data
• Data at rest
• Data in action
Using Versions to manage Formats
• Data formats and versions
• File formats and versions
• Implementing conversions
5. Implementing Documents on macOS: NSDocument and NSDocumentController
Chapters 5 and 6 have the same outline but the content is different from iOS and macOS
There are two main implementation issues on macOS:
• Browsing files
• Recents
• New Documents
• Renaming
• Deleting
• Using document files
• Reading
• Writing
6. Implementing Documents on IOS: UIDocument and UIDocumentBrowserViewController
Chapters 6 and 7 have the same outline but the content is different from iOS and macOS
There are two main implementation issues on iOS:
• Browsing files
• Recents
• New Documents
• Renaming
• Deleting
• Using document files
• Reading
• Writing
7. Sharing Documents with Share Buttons and UIActivityViewController
Your document formats work well with share buttons where you can share all or part of your documents. This chapter provides the structure for implementing share buttons for documents.
8. Crossing Platforms with Documents
This chapter explores the issues involved in using documents across platforms and the steps to take to make that work easily.
• Making Documents for iOS and macOS Compatibility
• Objects, structures and formats that need conversion
• Handling document conflicts in iCloud
• Providing Compatibility with Major Platforms
• Playing Nice with Microsoft Office and Related Apps
• Collaborating with Google Docs
• Sharing with Microsoft OneDrive
• Open Office and Other Formats
III. Building Other Data Storage Tools
9. Using User Defaults for Data and Settings on iOS Devices
10. Using User Defaults for Data and Settings on macOS Devices
11. Adding new Document Formats
• Open Formats (.doc, etc.)
• Shared Formats
• For Your Apps and Groups
• For Other Apps and Groups
• Building Composite Documents with File Managers
Jesse Feiler is a developer, consultant, and author specializing in database technologies and location-based apps. Jesse’s apps include NP Risk, Minutes Machine, Utility Smart, Cyber Continuity, and Saranac River Trail. He has worked for organizations as varied as Federal Reserve Bank of New York (Chief, Special Projects Staff in Systems Development), Albers and Archipenko foundations (data management), and a number of database projects typically using FileMaker. His apps are available in the App Store and are published by Champlain Arts Corp (champlainarts.com). Jesse is heard regularly on WAMC Public Radio for the Northeast's The Roundtable. founder of Friends of Saranac River Trail, Inc. A native of Washington DC, he has lived in New York City and currently lives in Plattsburgh NY.
Rise above the basics of Xcode app development to implement tools like Share buttons and activity view controllers to share document content including parts of documents with other users and with other devices. This book fills the gap so that developers with even a fundamental knowledge of iOS and Swift can implement document creation, saving, and sharing in their apps.
Since the launch of iPhone in 2007, users and developers have struggled with the fact that the file system is hidden. Fortunately the Files app in iOS 11 now offers this feature and it is supported by Apple apps such as Numbers, Pages, and Keynote as well as by the few third-party apps that support documents.
By using the standard formats described in this book, you can make your app’s data shareable to and from other apps like Numbers, Pages, and Word. Files also provides an interface to tools such as Dropbox and iCloud so that users can open and modify documents in them. If you combine standard formats such as .doc, .docx, .jpeg, and .jpg with Dropbox and eMail, you have a simple way to implement and use cross-platform sharing to Macs, PCs, and Android devices.
Implementing iOS and macOS Documents with the Files App provides the combination of skills developers need to build these types of apps—working with files and constructing documents.