Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch...
Transcript of Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch...
![Page 1: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/1.jpg)
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC14
Introducing the Photos Frameworks
Session 511 Adam Swift iOS Photos Frameworks
Media
![Page 2: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/2.jpg)
Introducing PhotoKit
Photos • Access photos and videos from photo library
• Create a full-featured app like built-in Photos app
Photos UI • Photo editing app extensions
![Page 3: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/3.jpg)
What You Will Learn
Photos framework • Fetch and manipulate photo library model data
• Handle external changes
• Retrieve and edit photo/video content
PhotosUI Framework • How to build photo/video editing extensions
![Page 4: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/4.jpg)
Photos Framework
![Page 5: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/5.jpg)
New Objective-C framework on iOS
First-class citizen • Custom image picker
• Full-featured photo library browser and editor
Introducing the Photos Framework
![Page 6: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/6.jpg)
New Objective-C framework on iOS
Make your app a first-class citizen of user’s Photo Library • Custom image picker
• Full featured photo
Used by built-in Photos and Camera app
Intended to supersede ALAssetsLibrary
New Objective-C framework on iOS
First-class citizen • Custom image picker
• Full-featured photo library browser and editor
Introducing the Photos Framework
![Page 7: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/7.jpg)
What Does It Provide?
Access photo and video assets, albums, and moments
Add, remove, modify assets and albums
Edit photo/video content and metadata
![Page 8: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/8.jpg)
Photos API Overview
Model data • Fetch model objects
• Change model data
• Handle model changes
Image and video content • Retrieve image/video content
• Edit content
![Page 9: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/9.jpg)
Model Data
![Page 10: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/10.jpg)
Model Objects
Represent the structure of your library • Photo and video assets, moments, albums, folders, etc.
Read-only
Thread-safe
![Page 11: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/11.jpg)
Model Objects
![Page 12: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/12.jpg)
Model Objects
Assets
![Page 13: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/13.jpg)
Model Objects
Assets
![Page 14: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/14.jpg)
Model Objects
Assets
![Page 15: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/15.jpg)
Model Objects
Assets
![Page 16: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/16.jpg)
Model Objects
Asset Collections
Assets
![Page 17: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/17.jpg)
Model Objects
Asset Collections
Assets
![Page 18: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/18.jpg)
Model Objects
Asset Collections
Assets
![Page 19: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/19.jpg)
Model Objects
Asset Collections
Assets
![Page 20: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/20.jpg)
Model Objects
Asset Collections
Assets
Collection Lists
![Page 21: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/21.jpg)
Model Objects
Asset Collections
Assets
Collection Lists
![Page 22: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/22.jpg)
Model Objects
Asset Collections
Assets
Collection Lists
![Page 23: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/23.jpg)
Assets
Photos and videos
![Page 24: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/24.jpg)
Assets
Photos and videos
PHAsset • Media type
• Creation date
• Location
• Favorite
![Page 25: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/25.jpg)
Asset Collection
Ordered collection of assets
Albums, moments, and smart albums
![Page 26: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/26.jpg)
Asset Collection
Ordered collection of assets
Albums, moments, and smart albums
PHAssetCollection • Type
• Title
• Start and end date
![Page 27: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/27.jpg)
Collection List
Ordered collection of collections • Both asset collections and collection lists
Folder, moment year
![Page 28: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/28.jpg)
Collection List
Ordered collection of collections • Both asset collections and collection lists
Folder, moment year
PHCollectionList • Type
• Title
• Start and end date
![Page 29: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/29.jpg)
Fetching Model Objects
Fetch via class methods on model object
Fetch all video assets [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil]
![Page 30: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/30.jpg)
Fetching Model Objects
Fetch via class methods on model object
Fetch all video assets [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil]
Fetch all moments [PHAssetCollection fetchMomentsWithOptions:nil]
![Page 31: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/31.jpg)
Fetching Model Objects
Fetch via class methods on model object
Fetch all video assets [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil]
Fetch all moments [PHAssetCollection fetchMomentsWithOptions:nil]
Use options to filter and sort
![Page 32: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/32.jpg)
Fetching Collection Contents
Collections do not cache their contents
Fetch contents via class methods
![Page 33: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/33.jpg)
Fetching Collection Contents
Collections do not cache their contents
Fetch contents via class methods
Fetch assets in an asset collection [PHAsset fetchAssetsInAssetCollection:myAlbum options:nil]
![Page 34: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/34.jpg)
Transient Collections
Runtime-only transient collection • Search results, user selection
![Page 35: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/35.jpg)
Transient Collections
Runtime-only transient collection • Search results, user selection
Interchangeable with regular collections • Fetch contents
• Reuse your view controllers, etc.
!
![Page 36: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/36.jpg)
Transient Collections
Create a transient asset collection [PHAssetCollection transientAssetCollectionWithAssets:assets title:title]
![Page 37: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/37.jpg)
Fetch Results
Want synchronous, fast results
Results of a fetch can be very large • Don’t need all objects in memory at once
• Work in batches
![Page 38: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/38.jpg)
Fetch Results
Results returned in a PHFetchResult • Tracks IDs of the full result set
• Vends fully realized objects
• Similar API to NSArray
![Page 39: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/39.jpg)
Fetch Results
Results returned in a PHFetchResult • Tracks IDs of the full result set
• Vends fully realized objects
• Similar API to NSArray
Fetch result
![Page 40: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/40.jpg)
Fetch Results
Results returned in a PHFetchResult • Tracks IDs of the full result set
• Vends fully realized objects
• Similar API to NSArray
assets[n]Fetch result
![Page 41: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/41.jpg)
Fetch Results
Results returned in a PHFetchResult • Tracks IDs of the full result set
• Vends fully realized objects
• Similar API to NSArray
assets[n]Fetch result
![Page 42: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/42.jpg)
Making Model Changes
Support for user actions • Favorite a photo
• Add to an album
Model objects are read-only, can’t mutate directly
![Page 43: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/43.jpg)
Change Requests API
Change request classes
Create in a change request block
Applied asynchronously out of process
![Page 44: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/44.jpg)
Change request class for each model class PHAssetChangeRequest PHAssetCollectionChangeRequest PHCollectionListChangeRequest
Provide model object–specific APIs setCreationDate: setFavorite:
Change Request Classes
![Page 45: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/45.jpg)
Not subclasses of model classes
Separates thread-safe, immutable model objects and mutations
Only valid within a change request block
Change Request Classes
![Page 46: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/46.jpg)
Change Request Example
- (void)toggleFavorite:(PHAsset *)asset { // Changes must be performed in a change block [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ !
// Create a change request for the asset PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest changeRequestForAsset:asset]; !
[changeRequest setFavorite:![asset isFavorite]]; } completionHandler:^(BOOL success, NSError *error) { ... }];
![Page 47: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/47.jpg)
Change Request Example
- (void)toggleFavorite:(PHAsset *)asset { // Changes must be performed in a change block [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ !
// Create a change request for the asset PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest changeRequestForAsset:asset]; !
[changeRequest setFavorite:![asset isFavorite]]; } completionHandler:^(BOOL success, NSError *error) { ... }];
![Page 48: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/48.jpg)
Change Request Example
- (void)toggleFavorite:(PHAsset *)asset { // Changes must be performed in a change block [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ !
// Create a change request for the asset PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest changeRequestForAsset:asset]; !
[changeRequest setFavorite:![asset isFavorite]]; } completionHandler:^(BOOL success, NSError *error) { ... }];
![Page 49: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/49.jpg)
Change Request Example
- (void)toggleFavorite:(PHAsset *)asset { // Changes must be performed in a change block [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ !
// Create a change request for the asset PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest changeRequestForAsset:asset]; !
[changeRequest setFavorite:![asset isFavorite]]; } completionHandler:^(BOOL success, NSError *error) { ... }];
![Page 50: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/50.jpg)
Change Request Example
- (void)toggleFavorite:(PHAsset *)asset { // Changes must be performed in a change block [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ !
// Create a change request for the asset PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest changeRequestForAsset:asset]; !
[changeRequest setFavorite:![asset isFavorite]]; } completionHandler:^(BOOL success, NSError *error) { ... }];
![Page 51: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/51.jpg)
Creating New Model Objects
Create via creation request request = [PHAssetChangeRequest creationRequestForAssetFromImage:image]
![Page 52: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/52.jpg)
Creating New Model Objects
Create via creation request request = [PHAssetChangeRequest creationRequestForAssetFromImage:image]
Placeholder objects placeholder = [request placeholderForCreatedAsset]
• Reference to a new, unsaved object
• Add to collections
• Can provide unique, persistent localIdentifier
![Page 53: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/53.jpg)
Whither Changes?
Changes are done when completion handler invoked
Model objects aren’t refreshed
Side effects and external changes!
![Page 54: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/54.jpg)
Handling Model Changes
Lots of sources of change • Your application, other applications
• iCloud Photo Library, iCloud Photo Sharing, My Photo Stream
![Page 55: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/55.jpg)
Handling Model Changes
Lots of sources of change • Your application, other applications
• iCloud Photo Library, iCloud Photo Sharing, My Photo Stream
![Page 56: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/56.jpg)
Change Notification
We publish a PHChange to registered observers • Delivered on a background queue
Details on updated and deleted objects
![Page 57: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/57.jpg)
Change Notification
We publish a PHChange to registered observers • Delivered on a background queue
Details on updated and deleted objects
Updated fetch results • Inserts, updates, deletes, and moves
![Page 58: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/58.jpg)
Fetch Result Change Details
Fetch results are implicitly registered for change details • Diffs calculated in the background
• Opt-out via fetch options
Get updated fetch result from the PHFetchResultChangeDetails
![Page 59: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/59.jpg)
Change Handling Example, Part One
- (void)photoLibraryDidChange:(PHChange *)change { // re-dispatch to main queue dispatch_async(dispatch_get_main_queue(), ^{ !
// get change details PHFetchResultChangeDetails *changeDetails = [change changeDetailsForFetchResult:self.assets]; !
// get the updated fetch results if (changeDetails) { self.assets = [changeDetails fetchResultAfterChanges]; ...
![Page 60: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/60.jpg)
Change Handling Example, Part One
- (void)photoLibraryDidChange:(PHChange *)change { // re-dispatch to main queue dispatch_async(dispatch_get_main_queue(), ^{ !
// get change details PHFetchResultChangeDetails *changeDetails = [change changeDetailsForFetchResult:self.assets]; !
// get the updated fetch results if (changeDetails) { self.assets = [changeDetails fetchResultAfterChanges]; ...
![Page 61: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/61.jpg)
Change Handling Example, Part One
- (void)photoLibraryDidChange:(PHChange *)change { // re-dispatch to main queue dispatch_async(dispatch_get_main_queue(), ^{ !
// get change details PHFetchResultChangeDetails *changeDetails = [change changeDetailsForFetchResult:self.assets]; !
// get the updated fetch results if (changeDetails) { self.assets = [changeDetails fetchResultAfterChanges]; ...
![Page 62: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/62.jpg)
Change Handling Example, Part One
- (void)photoLibraryDidChange:(PHChange *)change { // re-dispatch to main queue dispatch_async(dispatch_get_main_queue(), ^{ !
// get change details PHFetchResultChangeDetails *changeDetails = [change changeDetailsForFetchResult:self.assets]; !
// get the updated fetch results if (changeDetails) { self.assets = [changeDetails fetchResultAfterChanges]; ...
![Page 63: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/63.jpg)
Change Handling Example, Part One
- (void)photoLibraryDidChange:(PHChange *)change { // re-dispatch to main queue dispatch_async(dispatch_get_main_queue(), ^{ !
// get change details PHFetchResultChangeDetails *changeDetails = [change changeDetailsForFetchResult:self.assets]; !
// get the updated fetch results if (changeDetails) { self.assets = [changeDetails fetchResultAfterChanges]; ...
![Page 64: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/64.jpg)
Change Handling Example, Part Two
[collectionView performBatchUpdates:^{ if ([[changeDetails removedIndexes] count]) { NSArray *removedIndexPaths = // make indexPaths from indexes [collectionView deleteItemsAtIndexPaths:removedIndexPaths]; } if ([[changeDetails insertedIndexes] count]) { NSArray *insertedIndexPaths = ... [collectionView insertItemsAtIndexPaths:insertedIndexPaths]; } if ([[changeDetails changedIndexes] count]) { NSArray *changedIndexPaths = ... [collectionView reloadItemsAtIndexPaths:changedIndexPaths]; }
![Page 65: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/65.jpg)
Change Handling Example, Part Two
[collectionView performBatchUpdates:^{ if ([[changeDetails removedIndexes] count]) { NSArray *removedIndexPaths = // make indexPaths from indexes [collectionView deleteItemsAtIndexPaths:removedIndexPaths]; } if ([[changeDetails insertedIndexes] count]) { NSArray *insertedIndexPaths = ... [collectionView insertItemsAtIndexPaths:insertedIndexPaths]; } if ([[changeDetails changedIndexes] count]) { NSArray *changedIndexPaths = ... [collectionView reloadItemsAtIndexPaths:changedIndexPaths]; }
![Page 66: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/66.jpg)
Change Handling Example, Part Two
[collectionView performBatchUpdates:^{ if ([[changeDetails removedIndexes] count]) { NSArray *removedIndexPaths = // make indexPaths from indexes [collectionView deleteItemsAtIndexPaths:removedIndexPaths]; } if ([[changeDetails insertedIndexes] count]) { NSArray *insertedIndexPaths = ... [collectionView insertItemsAtIndexPaths:insertedIndexPaths]; } if ([[changeDetails changedIndexes] count]) { NSArray *changedIndexPaths = ... [collectionView reloadItemsAtIndexPaths:changedIndexPaths]; }
![Page 67: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/67.jpg)
Change Handling Example, Part Two
[collectionView performBatchUpdates:^{ if ([[changeDetails removedIndexes] count]) { NSArray *removedIndexPaths = // make indexPaths from indexes [collectionView deleteItemsAtIndexPaths:removedIndexPaths]; } if ([[changeDetails insertedIndexes] count]) { NSArray *insertedIndexPaths = ... [collectionView insertItemsAtIndexPaths:insertedIndexPaths]; } if ([[changeDetails changedIndexes] count]) { NSArray *changedIndexPaths = ... [collectionView reloadItemsAtIndexPaths:changedIndexPaths]; }
![Page 68: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/68.jpg)
Demo
![Page 69: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/69.jpg)
Image and Video Data
Karl Hsu iOS Photos Frameworks
![Page 70: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/70.jpg)
Requesting Image and Video Data
A variety of image sizes might be available • Some sizes might not be cached
• Videos might even be streaming
![Page 71: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/71.jpg)
PHImageManager
Request images based on target size
Request videos based on usage
Asynchronous API
Optionally retrieve data from the network
![Page 72: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/72.jpg)
Requesting Images
// Request image data for a square grid with cells of 160x160 pixels [manager requestImageForAsset:photo targetSize:CGSizeMake(160,160) contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage *result, NSDictionary *info) { if (result) { [cell setImage:result]; } else { ... } }];
![Page 73: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/73.jpg)
Advanced Image Requests
// Create Image Request object PHImageRequestOptions *options = [PHImageRequestOptions new]; !
// Fetch the image from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(BOOL degraded, double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestImageForAsset:... options:options ...];
![Page 74: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/74.jpg)
Advanced Image Requests
// Create Image Request object PHImageRequestOptions *options = [PHImageRequestOptions new]; !
// Fetch the image from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(BOOL degraded, double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestImageForAsset:... options:options ...];
![Page 75: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/75.jpg)
Advanced Image Requests
// Create Image Request object PHImageRequestOptions *options = [PHImageRequestOptions new]; !
// Fetch the image from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(BOOL degraded, double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestImageForAsset:... options:options ...];
![Page 76: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/76.jpg)
Advanced Image Requests
// Create Image Request object PHImageRequestOptions *options = [PHImageRequestOptions new]; !
// Fetch the image from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(BOOL degraded, double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestImageForAsset:... options:options ...];
![Page 77: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/77.jpg)
Image Request Callbacks
[manager requestImageForAsset: ... ^(UIImage *result, NSDictionary *info) { // This block can be called multiple times }];
![Page 78: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/78.jpg)
[manager requestImageForAsset: ... ^(UIImage *result, NSDictionary *info) { // This block can be called multiple times }];
Image Request Callbacks
First callback synchronous
![Page 79: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/79.jpg)
Image Request Callbacks
[manager requestImageForAsset: ... ^(UIImage *result, NSDictionary *info) { // This block can be called multiple times }];
First callback synchronous
![Page 80: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/80.jpg)
[manager requestImageForAsset: ... ^(UIImage *result, NSDictionary *info) { // This block can be called multiple times }];
Image Request Callbacks
First callback synchronous Second callback asynchronous
![Page 81: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/81.jpg)
Requesting Videos
// Request a playback item for video playback [manager requestPlayerItemForVideo:video options:nil resultHandler:^(AVPlayerItem *item, NSDictionary *info) { AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; }]; !
![Page 82: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/82.jpg)
// Create Video Request object PHVideoRequestOptions *options = [PHVideoRequestOptions new]; !
// Make sure we have the best quality options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat; !
// Fetch the video from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestExportSessionForVideo:video options:options ...];
Advanced Video Requests
![Page 83: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/83.jpg)
// Create Video Request object PHVideoRequestOptions *options = [PHVideoRequestOptions new]; !
// Make sure we have the best quality options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat; !
// Fetch the video from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestExportSessionForVideo:video options:options ...];
Advanced Video Requests
![Page 84: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/84.jpg)
// Create Video Request object PHVideoRequestOptions *options = [PHVideoRequestOptions new]; !
// Make sure we have the best quality options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat; !
// Fetch the video from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestExportSessionForVideo:video options:options ...];
Advanced Video Requests
![Page 85: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/85.jpg)
// Create Video Request object PHVideoRequestOptions *options = [PHVideoRequestOptions new]; !
// Make sure we have the best quality options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat; !
// Fetch the video from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestExportSessionForVideo:video options:options ...];
Advanced Video Requests
![Page 86: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/86.jpg)
// Create Video Request object PHVideoRequestOptions *options = [PHVideoRequestOptions new]; !
// Make sure we have the best quality options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat; !
// Fetch the video from iCloud if necessary and provide progress options.networkAccessAllowed = YES; options.progressHandler = ^(double progress, NSError *error, BOOL *stop) { [self updateUserVisibleProgress:progress error:error]; }; !
// Use the options to control the request behavior [manager requestExportSessionForVideo:video options:options ...];
Advanced Video Requests
![Page 87: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/87.jpg)
Scrolling Performance
Scrolling a grid of thumbnails
Maintain a cache around the visible range • Start caching ahead of the scroll
• Stop caching behind the scroll
![Page 88: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/88.jpg)
PHCachingImageManager
Preloads and caches images
Request against the caching image manager • Requests are resolved against cached data
Instance for each view controller
![Page 89: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/89.jpg)
Preheating
![Page 90: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/90.jpg)
Preheating
![Page 91: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/91.jpg)
Preheating
Visible Range
![Page 92: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/92.jpg)
Preheating
Start Caching
Visible Range
![Page 93: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/93.jpg)
Preheating
Start Caching
Stop Caching
Visible Range
![Page 94: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/94.jpg)
Preheating
Start Caching
Stop Caching
Visible Range
![Page 95: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/95.jpg)
PHCachingImageManager
// Use the same args as for requestImageForAsset PHCachingImageManager *cim = [self cachingImageManager]; !
!
NSArray *soonToBeVisibleAssets = ... [cim startCachingImagesForAssets:soonToBeVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil]; !
NSArray *previouslyVisibleAssets = ... [cim stopCachingImagesForAssets:previouslyVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil];
![Page 96: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/96.jpg)
PHCachingImageManager
// Use the same args as for requestImageForAsset PHCachingImageManager *cim = [self cachingImageManager]; !
!
NSArray *soonToBeVisibleAssets = ... [cim startCachingImagesForAssets:soonToBeVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil]; !
NSArray *previouslyVisibleAssets = ... [cim stopCachingImagesForAssets:previouslyVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil];
![Page 97: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/97.jpg)
PHCachingImageManager
// Use the same args as for requestImageForAsset PHCachingImageManager *cim = [self cachingImageManager]; !
!
NSArray *soonToBeVisibleAssets = ... [cim startCachingImagesForAssets:soonToBeVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil]; !
NSArray *previouslyVisibleAssets = ... [cim stopCachingImagesForAssets:previouslyVisibleAssets targetSize:targetSize contentMode:PHImageContentModeAspectFill options:nil];
![Page 98: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/98.jpg)
Editing Images and Videos
In-place • No need to save as a new asset
Nondestructive
Visible everywhere
Synced via iCloud Photo Library
![Page 99: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/99.jpg)
Editing Flow
Input Image
![Page 100: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/100.jpg)
Editing Flow
Input Image
![Page 101: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/101.jpg)
Editing Flow
Input Image30820bd806092a864886f70d010702a0820bc930820bc5020101310b300906052b0e03021a05003082013c06092a864886f70d010701a082012d048201297b226163746976697479636f6e74696e7561
Your Code
![Page 102: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/102.jpg)
Your Code
Editing Flow
Input Image
![Page 103: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/103.jpg)
Your Code
Editing Flow
Output Image
![Page 104: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/104.jpg)
Getting Input
// Get the input from the asset [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *editingInput, NSDictionary *info) { !
!
!
!
!
!
!
}
![Page 105: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/105.jpg)
Getting Input
// Get the input from the asset [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *editingInput, NSDictionary *info) { NSURL *url = [editingInput fullSizeImageURL]; int orientation = [editingInput fullSizeImageOrientation]; !
CIImage *inputImage = [CIImage imageWithContentsOfURL:url options:nil]; inputImage = [inputImage imageByApplyingOrientation:orientation]; !
// Your code here }
![Page 106: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/106.jpg)
Saving Output
// Create the output PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:input]; [jpegData writeToURL:output.renderedContentURL atomically:YES]; output.adjustmentData = adjustmentData; !
![Page 107: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/107.jpg)
Saving Output
// Create the output PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:input]; [jpegData writeToURL:output.renderedContentURL atomically:YES]; output.adjustmentData = adjustmentData; !
// Save the output to the asset [library performChanges:^{ PHAssetChangeRequest *request = ... [request setContentEditingOutput:contentEditingOutput]; } completionHandler:^(BOOL success, NSError *error) {}];
![Page 108: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/108.jpg)
Resumable Edits
![Page 109: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/109.jpg)
Resumable Edits
Noir, 100%+ =Adjustment Data
![Page 110: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/110.jpg)
Resumable Edits
Input
Noir, 100%+ =Adjustment Data
![Page 111: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/111.jpg)
Resumable Edits
Output
Input
Noir, 100%+ =Adjustment Data
![Page 112: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/112.jpg)
Saving Adjustment Data
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:settings]; !
PHAdjustmentData *adjustmentData = [[PHAdjustmentData alloc] initWithFormatIdentifier:@"com.mycompany" formatVersion:@"1.0" data:archivedData]; !
PHContentEditingOutput *output = ... output.adjustmentData = adjustmentData;
![Page 113: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/113.jpg)
Adjustment Data
PHContentEditingInputRequestOptions *options = … !
// Do you understand the current adjustment options.canHandleAdjustmentData:^BOOL(PHAdjustmentData *adjustmentData) { !
}
![Page 114: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/114.jpg)
Adjustment Data
PHContentEditingInputRequestOptions *options = … !
// Do you understand the current adjustment options.canHandleAdjustmentData:^BOOL(PHAdjustmentData *adjustmentData) { return [adjustmentData.formatIdentifier isEqual:@"com.mycompany"] && [adjustmentData.formatVersion isEqual:@"1.0"]; }
![Page 115: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/115.jpg)
Adjustment Understood? Yes!
Input
Noir, 100%+ =Adjustment Data
![Page 116: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/116.jpg)
Adjustment Understood? No.
Input
Noir, 100%+ =Adjustment Data
![Page 117: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/117.jpg)
Demo
![Page 118: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/118.jpg)
Photo Editing ExtensionsPhotosUI framework
Simon Bovet iOS Photos Frameworks
![Page 119: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/119.jpg)
Photo Editing Extension
Your image or video editor
Available from built-in Photos and Camera apps
![Page 120: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/120.jpg)
![Page 121: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/121.jpg)
![Page 122: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/122.jpg)
![Page 123: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/123.jpg)
![Page 124: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/124.jpg)
What’s Needed
App extension target
UIViewController subclass
Protocol adoption
![Page 125: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/125.jpg)
What’s Needed
App extension target
UIViewController subclass
Protocol adoption
![Page 126: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/126.jpg)
Xcode Template
Add new target to your app’s project
Choose “Photo Editing Extension”
![Page 127: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/127.jpg)
User Interface
Navigation bar displayed by Photos app
Avoid navigation bar-based design for your extension
Your extension’s UI
![Page 128: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/128.jpg)
What’s Needed
App extension target
UIViewController subclass
Protocol adoption
![Page 129: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/129.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
![Page 130: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/130.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
![Page 131: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/131.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
![Page 132: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/132.jpg)
Getting Input
- (void)startContentEditingWithInput:(PHContentEditingInput *)input placeholderImage:(UIImage *)placeholderImage { UIImage *image = input.displaySizeImage; !
id settings = [self settingsFromAdjustmentData:input.adjustmentData]; if (!settings) { settings = [self defaultSettings]; } !
... // set up user interface self.input = input; }
![Page 133: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/133.jpg)
Getting Input
- (void)startContentEditingWithInput:(PHContentEditingInput *)input placeholderImage:(UIImage *)placeholderImage { UIImage *image = input.displaySizeImage; !
id settings = [self settingsFromAdjustmentData:input.adjustmentData]; if (!settings) { settings = [self defaultSettings]; } !
... // set up user interface self.input = input; }
![Page 134: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/134.jpg)
Getting Input
- (void)startContentEditingWithInput:(PHContentEditingInput *)input placeholderImage:(UIImage *)placeholderImage { UIImage *image = input.displaySizeImage; !
id settings = [self settingsFromAdjustmentData:input.adjustmentData]; if (!settings) { settings = [self defaultSettings]; } !
... // set up user interface self.input = input; }
![Page 135: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/135.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
Your extension’s UI
![Page 136: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/136.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
Your extension’s UI
![Page 137: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/137.jpg)
Saving Output
- (void)finishContentEditingWithCompletionHandler: (void (^)(PHContentEditingOutput *))completionHandler { NSData *jpegData = ...; PHAdjustmentData *adjustmentData = ...; !
PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input]; [jpegData writeToURL:output.renderedContentURL atomically:YES]; output.adjustmentData = adjustmentData; !
completionHandler(output); }
![Page 138: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/138.jpg)
Saving Output
- (void)finishContentEditingWithCompletionHandler: (void (^)(PHContentEditingOutput *))completionHandler { NSData *jpegData = ...; PHAdjustmentData *adjustmentData = ...; !
PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input]; [jpegData writeToURL:output.renderedContentURL atomically:YES]; output.adjustmentData = adjustmentData; !
completionHandler(output); }
![Page 139: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/139.jpg)
Saving Output
- (void)finishContentEditingWithCompletionHandler: (void (^)(PHContentEditingOutput *))completionHandler { NSData *jpegData = ...; PHAdjustmentData *adjustmentData = ...; !
PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input]; [jpegData writeToURL:output.renderedContentURL atomically:YES]; output.adjustmentData = adjustmentData; !
completionHandler(output); }
![Page 140: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/140.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
![Page 141: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/141.jpg)
Resuming Edits
- (BOOL)canHandleAdjustmentData:(PHAdjustmentData *)adjustmentData { return [adjustmentData.formatIdentifier isEqual:@"com.mycompany"] && [adjustmentData.formatVersion isEqual:@"1.0"]; }
![Page 142: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/142.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
Your extension’s UI
![Page 143: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/143.jpg)
Protocol AdoptionPHContentEditingController
startContentEditingWithInput:
finishContentEditingWithCompletionHandler:
canHandleAdjustmentData:
cancelContentEditing
Your extension’s UI
![Page 144: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/144.jpg)
What’s Needed
App extension target
UIViewController subclass
Protocol adoption
![Page 145: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/145.jpg)
Demo
![Page 146: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/146.jpg)
Summary
Photos framework • Access photos and videos
• Build a full-featured app like the Photos app
Photo editing extensions
![Page 147: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/147.jpg)
More Information
Allan Schaffer Graphics and Game Technologies Evangelist [email protected]
!
Documentation Photos Reference http://developer.apple.com
Apple Developer Forums http://devforums.apple.com
![Page 148: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/148.jpg)
Related Sessions
• Creating Extensions for iOS and OS X, Part One Mission Tuesday 2:00PM
• Creating Extensions for iOS and OS X, Part Two Mission Wednesday 11:30AM
• Camera Capture: Manual Controls Marina Wednesday 11:30AM
• Advances in Core Image Pacific Heights Thursday 2:00PM
• Developing Core Image Filters for iOS Pacific Heights Thursday 3:15PM
![Page 149: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/149.jpg)
Labs
• Photos Framework Lab Media Lab A Thursday 11:30AM
• Extensions Lab Frameworks Lab B Thursday 2:00PM
• Photos Framework Lab Media Lab B Friday 10:15AM
![Page 150: Introducing the Photos Frameworks - Apple Inc. · What You Will Learn Photos framework • Fetch and manipulate photo library model data • Handle external changes • Retrieve and](https://reader035.fdocuments.in/reader035/viewer/2022062604/5fbee3555cb8cc3236205cdd/html5/thumbnails/150.jpg)