Managing Documents in your iOS Apps

WWDC 2018

Posted by Den on July 19, 2018 · 8 mins read
Managing Documents in your iOS Apps

Managing Documents in your iOS Apps

WWDC 2018

Managing Documents in your iOS Apps

WWDC 2018

Client API

File Provider API

Validation tool

Siri Shortcuts

  • File Provider Extension → Info.plist → 
    Add NSFileProviderUsesUniqueItemIdentifiersAcrossDevices

Sample App

Document Picker vs Document Browser

UIDocumentBrowserViewController

  • Starting point of your app
    Best practice is to make it the rootViewController
  • Full screen
  • Open and organize your documents
  • All the features of the Files App
  • Can be customized
  • Present your own UI on top

UIDocumentPickerViewController

  • Access files in the cloud (.open)
  • Move files to the cloud (.moveToService)
  • Copy from/to the cloud (.import, .exportToService)

Example

Document Types

  • let the system know which files your application handles

2 Steps

  • Declaring the type if it isn’t already declared by iOS
  • Claiming that you can view or edit files of this type

Declaring a Type

Declaring a New File Type

  • My type conforms to public.data, public.content

Type Conformance

Claiming Support for a Type

Your App and the Sandbox

Coordinating File Access

  • NSFileCoordinator, NSFIlePresenter
  • Wide Multiple reader/single writer lock
  • Instructs the system to download the document

Restore the UI State

How do we implement it?

  • Use a Bookmark

Encode/ Decode restorableState example

Encode/ Decode restorableState example

Open In Place