234 Buildingdocumentbasedapps
234 Buildingdocumentbasedapps
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
What’s a Document Based App?
General characteristics
What’s a Document Based App?
General characteristics
Doc Doc
1 2
Doc
3
Doc Doc
4 5
NSURL 2
Doc
3
Doc Doc
4 5
NSFileManager APIs
Other App’s Container
Document Browser
Discovering documents
Your App’s Container
NSURL 2
Doc
3
Doc Doc
4 5
NSFileManager APIs
Other App’s Container
Document Browser
Discover documents with NSMetadataQuery
Your App’s Container
Doc Doc
1 2
Doc
3
Doc Doc
4 5
NSMetadataItem 2
Doc
3
NSMetadataItem 3
NSMetadataQuery APIs
Other App’s Container
Document Browser
Discover documents with NSMetadataQuery
Your App’s Container
NSMetadataItem 2
Doc
3
NSMetadataItem 3
NSMetadataQuery APIs
Other App’s Container
Document Browser
NSMetadataQuery
Your App’s Container
Doc Doc
1 2
Doc
3
Doc Doc
4 5
Doc Doc
1 2
Doc
3
Doc Doc
4 5
Create NSMetadataQuery
Other App’s Container
Document Browser
NSMetadataQuery
Your App’s Container
NSMetadataItem 2
Doc
3
NSMetadataItem 3
NSMetadataItem 2
Doc
3
NSMetadataItem 3
NSMetadataItem 2
Doc Doc
3 6
NSMetadataItem 3
Update Notifications
Other App’s Container
Document Browser
NSMetadataQuery
Your App’s Container
NSMetadataItem 2
Doc Doc
3 6
NSMetadataItem 3
Compute Animations
Other App’s Container
Document Browser
NSMetadataQuery
Your App’s Container
NSMetadataItem 2
Doc Doc
3 6
NSMetadataItem 3
Display Updated UI
Other App’s Container
Loading Thumbnails
Document Browser
Thumbnails
Document Browser
Thumbnails
Main Queue
Background
Queue
Document Browser
Loading thumbnails for display
Background
Queue
Document Browser
Loading thumbnails for display
Background
Fetch Thumbnail
Queue
Document Browser
Loading thumbnails for display
Display Cell
Main Queue Load Cell
With Placeholder
Background
Fetch Thumbnail
Queue
Document Browser
Loading thumbnails for display
Display Cell
Main Queue Load Cell Reload Cell
With Placeholder
Background
Fetch Thumbnail
Queue
Document Browser
Loading thumbnails for display
Background
Fetch Thumbnail
Queue
Managing a Recents List
Recents List
Storing recently-used items list
Recents List
Storing recently-used items list
Doc
1
NSURL
Recents List
Storing recently-used items list
NSURL
Doc
1
Recents List
Storing recently-used items list
NSURL
Doc
1
Recents List
Use security scoped bookmarks
Doc
1
Bookmark
Recents List
Use security scoped bookmarks
Bookmark
Doc
1
Recents List
Use security scoped bookmarks
Bookmark
Doc
1
Demo
Document Browser Summary
Document Browser Summary
Your App
Document Access
File coordination and presentation
Write
Your App
Document Access
File coordination and presentation
Write Write
Your App
Document Access
File coordination and presentation
Write Write
Your App
Other App
Document Access
File coordination and presentation
Write Write
Your App
Read
Other App
Document Access
File coordination and presentation
Write Write
Your App
Inconsistent
Read Read
Other App
Document Access
File coordination and presentation
Write Write
Your App
Inconsistent
Read Read Stale Display
Other App
Document Access
File coordination and presentation
Write Write
Your App
Write Write
Your App
Write Write
Your App
Write Write
Your App
Write Write
Your App
Goals
Document Management
Creating new documents
Goals
• Consistent
Document Management
Creating new documents
Goals
• Consistent
• Up-to-date
Document Management
Creating new documents
Goals
• Consistent
• Up-to-date
Your App
Document Management
Creating new documents
Goals
• Consistent
• Up-to-date
Goals
• Consistent
• Up-to-date
Goals
• Consistent
• Up-to-date
Background
queue
Document Management
Creating new documents
Background
Document Creation
queue
Document Management
Creating new documents
Background
Document Creation
queue
Document Management
Creating new documents
Background
Document Creation
queue
Loading and Displaying
Reading documents
Main
thread
Background
queue
Loading and Displaying
Reading documents
Main
open
thread
Background
queue
Loading and Displaying
Reading documents
Main
open
thread
Main
open
thread
Main
open completion
thread
Main
open completion
thread
Main
open completion
thread
Main
open completion
thread
Main
open State Change completion
thread
Main
open State Change Progress display completion
thread
Main
open State Change Progress display State Change completion
thread
Background
queue
Loading and Displaying
Writing documents
Doc 1 Doc 1
_v1 _v2
Opening from Other Apps
iOS 8—Open by copy
Doc 1
_v1
Opening from Other Apps
iOS 9—Open in place
Doc 1 Doc 1
_v1 _v1
Opening from Other Apps
iOS 9—Open in place
Doc 1 Doc 1
_v1 _v1
Opening from Other Apps
iOS 9—Open in place
Doc 1 Doc 1
_v1 _v1
Opening from Other Apps
Supporting open in place
Opening from Other Apps
Supporting open in place
Support is simple
Opening from Other Apps
Supporting open in place
Support is simple
• LSSupportsOpeningDocumentsInPlace key in Info.plist
Opening from Other Apps
Supporting open in place
Support is simple
• LSSupportsOpeningDocumentsInPlace key in Info.plist
• Adopt new delegate method
Opening from Other Apps
Handling open in place versus copy
return true
}
Opening from Other Apps
Handling open in place versus copy
return true
}
Opening from Other Apps
Handling open in place versus copy
return true
}
Summary
Summary
Sample Code
http://developer.apple.com/library/
prerelease/ios/samplecode/ShapeEdit
Technical Support
http://developer.apple.com/forums
iCloud Documentation
http://developer.apple.com/icloud
Related Sessions