인디노트

Photos Framework 정리 본문

소스 팁/Objective C, Swift, iOS, macOS

Photos Framework 정리

인디개발자 2018. 4. 1. 08:21
Photos Framework 정리

Framework Photos

iCloud Photo Library 및 Live Photo 및 Photos 앱에 의해 관리되는 image 및 video asset을 가지고 작업합니다. 풀 크기의 asset 또는 thumbnail 이미지를 비동기적으로 가져오거나 cache 처리하며, 내용을 수정하고, 수정된 내용을 여러 장치에 동기화 합니다.

개요

iOS 및 macOS에서, Photos framework는 Photos앱을 위한 사진 편집 확장 기능을 지원하는 class를 제공합니다. iOS 및 tvOS에서, Photos framework는 Photos앱 및 iCloud Photo Library에서 관리하는 photo 및 video asset에 직접 액세스 할 수 있습니다. 이 framework을 사용하여 display 및 playback할 asset을 검색하거나 image 또는 video content을 편집하거나 앨범들, 순간들 및 iCloud 공유 앨범과 같은 asset collection을 사용하여 작업할 수 있습니다.

특징 & 개념

iOS 및 tvOS에서, Photos framework는 직접적으로 유저의 Photos library을 가지고 작업하기 위한 여러 가지 기능을 가지고 있습니다.

  • 객체들을 가져오고 변경을 요청합니다: Photos framework model 클래스들의 인스턴스들(PHAssetPHAssetCollection, and PHCollectionList)는 Photos 앱에서 작업하는 item들(assets(images, videos, Live Photos)), asset들의 collection(album들 or moment들), 그리고 collection들의 리스트(album folder들 or moment 모음들)이다. 이 객체들은 읽기전용이며, 변경불가능(immutable)이며, 오직 metadata만 포함합니다. 관심 있는 데이터를 가져와서 해당 객체를 사용하여 작업해야 하는 asset들 및 collection들을 가지고 작업할 수 있습니다. 변경 요청을 하려면 변경 요청 객체를 만들고 이를 공유되는 PHPhtoLibrary 객체에 명시적으로 커밋합니다. 이 아키텍처를 사용하면 여러 쓰레드 또는 여러 앱 및 앱 확장에서 동일한 asset을 사용하여 쉽고 안전하며 효율적으로 작업할 수 있습니다.
  • 변경 관찰: 공유되는 PHPhotoLibrary 객체를 사용하여 가져오는 asset들 및 collection들에 대한 change handler를 등록하십시오. Photos framework는 다른 앱이나 기기가 asset의 content 나 metadata 또는 collection에 있는 asset 목록을 변경할 때마다 앱에 알려줍니다. PHChange 객체는 변경 사항 전후에 객체 상태에 대한 정보를 제공하여 객체가 Collection view 또는 유사한 인터페이스를 쉽게 업데이트 할 수 있도록합니다.
  • Photos앱의 기능들 지원. Photos앱에 있는 Moments 계층에 해당하는 asset을 찾는데 PHCollectionList 클래스를 사용하십시오. Burst 사진들, 파노라마 사진들 및 높은 프레임 속도의 비디오를 식별하려면 PHAsset을 사용하십시오. iCloud Photo Library가 활성화될때, Photos framework안에 있는 asset들과 collection들에는 동일 iCloud 계정의 모든 장치에서 사용할 수 있는 내용이 반영됩니다.
  • Asset과 thumbnail 로딩 및 캐싱. Video asset들을 가지고 작업할 AVFoundation 객체 or 지정된 크기에 asset들의 이미지들을 요청하기 위해서는PHImageManager클래스를 사용하십시오. Photos framework는 자동으로 요청된 사양에 맞게 이미지를 자동으로 다운로드 또는 생성하며 빠른 재사용을 위해 캐싱합니다. 아주 많은 양의 asset을 가지고 빠른 퍼포먼스를 위해(예, thumbnail들을 가진 collection view를 계산할 때) PHCachingImageManager 서브클래스는 대량 사전 로드(preloading)을 추가합니다.
  • Asset content 편집PHAsset과 PHAssetChangeRequest클래스들은 편집을 위해 사진(photo) 혹은 비디오(video) 내용을 요청하고 Photos library에 편집된 내용을 커밋하는 메소드를 정의합니다. 서로 다른 앱들과 확장간에 편집의 연속성을 유지하기 위해, Photos framework는 각 asset의 현재 version 및 이전 version을 마지막 편집을 서술하는 PHAdjustmentData객체와 함께 유지합니다. 앱이 이전 수정 사항의 조정 데이터를 지원하는 경우 사용자가 수정 사항을 되돌리거나 변경하도록 허용할 수 있습니다.

iOS 및 macOS에서, Photos framework는 Photos앱에 사용되는 사진 편집 확장 프로그램을 개발하는데 사용되는 클래스들을 제공합니다. 그러나 확장의 주요 클래스들은 PhotosUI framework에서 정의한 PHContentEditingController 프로토콜을 채택해야 합니다. Photos앱 확장에 대한 자세한 내용은 App Extension programming guide 및 PhotosUI를 참조하세요.

Symbols

Photos Library와 상호작용

1. 여러분의 앱이 Photo들에 접근하는데에 user의 permission을 얻어오기 위해 사용해라.

2. asset들과 collection들에 변경들을 수행하고 싶을 때 사용해라.

3. Photos library가 변경되었을 때, 수신 받는 업데이트 메시지를 등록하고 싶을 때 사용해라.

PHPhotoLibrary — 유저의 Photos library안에 사진들에 접근들 및 변경들을 관리하는 공유되는 객체이다.

Asset들 검색과 조사

이러한 model 클래스들은 Photos library의 content(assets, collections)을 나타낸다. 이 클래스들의 인스턴스들은 읽기전용, 변경 불가능 이며, metadata만 포함한다. asset들과 collection들을 사용하려면 이 클래스를 사용하여 지정된 쿼리와 일치하는 객체 셋트를 가져온다.

PHAsset — Photos library에 있는 image, video or Live Photo를 나타낸다.

PHAssetCollection — moment, 유저가 생성한 album, or smart album와 같은 그룹된 Photos asset을 나타낸다.

PHCollectionList — user가 생성한 album들, moment들 연도와 같은 Photos asset collection들이 포함된 그룹을 나타낸다.

PHCollection — Photos asset collections 및 collection lists에 대한 추상 슈퍼클래스이다.

PHObject — Photos model 객체들에 대한 추상 슈퍼클래스이다. (Asset 및 collections)

PHFetchResult — Photos fetch 메소드에서 리턴된 정렬된 assets or collections,

PHFetchOptions — Asset or collection 객체를 가져올 때 Photos에서 반환하는 결과의 필터링, 정렬 및 관리에 영향을 주는 옵션들의 셋트이다.

Asset 내용 로딩

Photos assets와 연관된 image, video, or Live Photo content를 요청하고 싶다면 이 클래스들을 사용해라. Photos 지정된 사양에 맞게 이미지를 자동으로 다운로드 혹은 생성하며 빠른 재사용을 위해 캐싱합니다. 또한 대량의 asset들을 가지고 빠른 퍼포먼스를 낼 수 있도록 이미지를 일괄적으로 미리로드 하도록 요청할 수 있다.

PHImageManager — Photos assets와 연관된 미리보기 thumbnail들 및 풀 사이즈 image 혹은 video data를 찾거나 생성하는데에 사용되는 메소드를 제공한다.

PHCachingImageManager — 대량의 Asset을 일괄적으로 미리로드하기 위해 최적화된 Photos asset과 관련된 미리보기 thumbnail들 및 풀 사이즈 image or video data를 찾거나 생성하는데 사용되는 메소드를 제공합니다.

PHImageRequestOptions — image manager로 부터 요청한 Photos assets의 still image 표현들에 영향을 주는 옵션들의 셋트이다.

PHVideoRequestOptions — image manager로 부터 요청한 video asset data의 배달에 영향을 주는 옵션들의 셋트이다.

PHLivePhotoRequestOptions — image manager로 부터 요청한 Live Photo asset의 배달에 영향을 주는 옵션들의 셋트이다.

PHLivePhoto — capture 직전과 직후 순간들의 모션 및 사운드가 포함된 Live Photo을 실행할 수 있는 표현이다.

변경 요청

Asset들 or collection들을 변경하려면 편집 내용을 설명하는 change request 객체를 만들고 명시적으로 Photos library에 커밋해라. 이 아키텍처를 사용하면 여러 쓰레드 또는 여러 앱 및 앱 확장에서동일한 Asset을 가지고 쉽고, 안전하며 효율적으로 작업할 수 있습니다.

PHAssetChangeRequest — Photo library change block에서 사용하기 위해 Photos asset의 생성, 삭제, 메타 데이터 변경 또는 Photos의 content 편집 요청 객체

PHAssetCollectionChangeRequest — Photo library change block에서 사용하기 위해 Photos asset collection을 생성, 삭제, 또는 수정할 요청 객체

PHCollectionListChangeRequest — Photo library change block에서 사용하기 위해 Photos collection list을 생성, 삭제, 또는 수정할 요청 객체

PHObjectPlaceholder — Change request으로 아직 생성되지 않은 Photos asset or collection 객체를 나타내는 읽기 전용 프록시 이다.

Asset Content 편집

앱 또는 확장 앱에서 이러한 클래스를 사용하여 사진 라이브러리 편집 및 커밋 편집을 위해 Asset data에 액세스 합니다. Photo들은 각 수정 사항을 설명하는 여러 버전의 Asset들 및 adjustment data를 관리하므로 앱 또는 확장 앱을 사용하여 다른 기기에서도 이전에 수정 한 내용을 되돌리거나 계속 사용할 수 있습니다. Photos 앱의 사진 편집 확장 기능을 만들려면 이 클래스들을 PhotosUI framework와 함께 사용하십시오.

PHContentEditingInput — 편집할 asset의 image, video 또는 live photo content에 대한 정보와 액세스 권한을 제공하는 container이다.

PHContentEditingOutput — Photos asset의 photo, video, or Live Photo content를 편집한 결과를 제공하는 container이다.

PHAdjustmentData — 앱의 이전 사진 편집 세션의 효과를 재구성하거나 되돌릴 수 있는 Asset의 photo, video, 또는 Live Photo content에 대한 수정 사항에 대한 설명입니다.

PHContentEditingInputRequestOptions — Photos asset의 content를 수정하도록 요청할 때 image 또는 video data 전송에 영향을 주는 옵션 셋트이다.

PHLivePhotoEditingContext — Live Photo의 photo, video 및 audio content을 수정하기 위한 편집 세션.

PHLivePhotoFrame — 편집 context에서 Live Photo의 단일 frame에 대한 image content를 제공하는 container이다.

변경 관찰

Photos framework는 다른 앱들, 다른 기기 또는 코드가 collection에 있는 asset들 또는 asset list의 content 또는 metadata를 변경할 때마다 앱에 알려준다. 이 객체들은 변경 전후의 객체 상태에 대한 정보를 제공하므로 사용자 인터페이스를 쉽게 업데이트하여 일치 시킬 수 있습니다.

PHPhotoLibraryChangeObserver — Photos library에서 발생한 변경 사항을 알리기 위해 구현할 수 있는 프로토콜 이다.

PHChange — Photos library에서 발생한 변경 사항에 대한 설명이다.

PHObjectChangeDetails — asset or Collection 객체에서 발생한 변경사항에 대한 설명이다.

PHFetchResultChangeDetails — fetch 결과에 나열된 Asset or collection 객체들의 셋트에서 발생한 변경 사항에 대한 설명

Asset Resource들을 가지고 작업

하나 이상의 Asset resource 객체가 각 Photos asset의 data 저장소를 나타냅니다. 이러한 객체를 사용하여 asset을 직접 백업하고 복원하는 것과 같이 이러한 자원을 직접 사용해라.

PHAssetResource — Photos library에 있는 photo, video, Live Photo asset과 관련된 data resource이다.

PHAssetCreationRequest — Photo library change block에서 사용하기 위해 data resource에서 새로운 Photos asset을 생성할 요청

PHAssetResourceCreationOptions — resource들에서 새로운 Photos asset을 만드는 데에 영향을 주는 옵션 셋트이다.

PHAssetResourceManager — Photos asset과 관련된 resource에 대한 data 저장소에 액세스하는 방법을 제공한다.

PHAssetResourceRequestOptions — Asset resource manager가 요청한 asset data의 전달에 영향을 주는 옵션 셋트이다.

Media Type들 과 Subtype들

PHAsset 및 PHContentEditingInput 클래스와 함께 사용되어 여러 가지 종류의 Asset을 식별하거나 요청하는 상수 입니다.

PHAssetMediaType — Image or video와 같은 asset의 일반적인 type을 식별하는 상수들이다.

PHAssetMediaSubtype — 파라노마 또는 스크린 샷 Photo, 시간 경과 또는 높은 frame 속도 video와 같은 asset media의 특정 변형들을 식별하는 상수.

WWDC 2014: Introducing the Photos Frameworks

iOS 8 부터 ALAssetsLibrary를 대체하기 위해 만들었다.

Photo 및 Video asset들, album들, moment들을 접근할 수 있다.

asset들 및 앨범들을 추가, 삭제, 수정할 수 있다.

Photo/video content 및 metadata를 편집할 수 있다.

Model Data

Model Objects

library의 구조를 나타낸다.

Photo 및 video asset들, moment들, album들, folder들 등등

읽기 전용이다.

Thread에 안전하다.

Assets

Photos 및 videos를 나타낸다.

PHAsset

* Media type

* Creation date

* Location

* Favorite

Asset Collection

정렬된 asset들의 collection

Albums, moments, smart albums

PHAssetCollection

* Type

* Title

* Start and end date

Collection List

collections의 정렬된 collection

* asset collections 및 collection lists

Folder, moment year

PHCollectionList

* Type

* Title

* Start and end date

Fetching Model Objects

Model객체에 있는 Class method들을 통해 fetch.

모든 video assets fetch

[PHAsset fetchAssetsWithMediaType: PHAssetMediaTypeVideo options: nil];

모든 moments fetch

[PHAssetCollection fetchMomentsWithOptions: nil];

Filter 및 sort options을 사용해라

Fetching Collection Contents

Collections은 content들을 캐쉬하지 않는다.

Class method들을 통해 Fetch

Asset collection에 있는 assets를 fetch

[PHAsset fetchAssetsInAssetCollection: myAlbum options:nil];

Transient Collections

오직 Runtime, transient collection

* 결과들 검색, user 선택

정규 collections을 가지고 교환할 수 있음

* contents를 Fetch

* 당신의 view controller을 재사용할 수 있다.

Transient asset collection 생성하기

[PHAssetCollection transientAssetCollectionWithAssets: assets title: title];

Fetch Results

Synchronous, fast results를 원함

Fetch 결과들은 매우 크다.

* 메모리에 한번에 모든 객체는 필요하지 않다.

* batchs안에서 작업

PHFetchResult에 있는 리턴된 Results

* full result 셋트의 ID들을 추적한다.

* 완벽하게 실현된 객체들을 제공

* NSArray와 비슷한 API

Making Model Changes

User actions에 대한 지원

* photo를 Favorite

* album에 추가

Model 객체들은 읽기 전용이다, 직접적으로 수정할 수 없다.

Change Requests API

Change request classes

Change request block안에서 생성

Process 밖에서 비동기적으로 적용

Change Request Classes

각 Model class을 위한 Change request class

PHAssetChangeRequest

PHAssetCollectionChangeRequest

PHCollectionListChangeRequest

특정 Model 객체의 APIs을 제공한다.

setCreationDate:

setFavorite:

Change Request class들은 Model class들의 subclass가 아니다.

Change Request class들은 Thread에 안전, 불변형 model 객체들, moments를 분리했다.

오직 Change request block 안에서만 유효하다.

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) { … }];
}

Creating New Model Objects

Creation request를 통한 생성

request = [PHAssetChangeRequest creationRequestForAssetFromImage: image];

Placeholder objects

placeholder = [request placeholderForCreatedAsset];

* 새로운 것을 참조, 저장되지 않는 객체

* collections에 추가

* 유일하고, 영구적인 localIdentifier를 제공할 수 있다.

Whither Changes?

Completion handler가 호출될때 Changes는 완료된다.

Model 객체들은 refresh 되지 않는다.

Side effects 및 external changes!

Handling Model Changes

변경의 sources가 많음

* 너의 앱, 다른 앱

* iCloud Photo Library, iCloud Photo Sharing, My Photo Stream

Change Notification

등록된 옵저버들에게 PHChange를 준다.

* background queue에서 전송된다.

업데이트 및 삭제된 객체들에 대한 디테일한 정보

업데이트된 fetch 결과들

* inserts, updates, deletes, and moves

Fetch Result Change Details

Fetch results은 change details에 대해 암시적으로 등록되어진다.

* 백그라운드에서 계산된 Diffs

* Fetch options을 통한 수신 거부

PHFetchResultChangeDetails으로 부터 업데이트된 fetch result를 얻어라.

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];
  }
 }
}

Change Handling Example, Part Two

[collectionView performBatchUpdates:^{
 if ([[changeDetails removedIndexes] count]) {
  NSArray *removedIndexPaths = // make indexPath from indexs
  [collectionView deleteItemsAtIndexPaths: removedIndexPath];
 }
 if ([[changeDetails insertedIndexs] count]) {
  NSArray *insertedIndexPaths = …
  [collectionView insertItemsAtIndexPaths: insertedIndexPaths];
}
 if ([[changeDetails changedIndexs] count]) {
  NSArray *changedIndexPaths = …
  [collectionView reloadItemsAtIndexPaths: changedIndexPaths];
 }
}

Image and Video Data

Requesting Image and Video Data

다양한 image size을 이용할 수 있다.

* 어떤 size들은 캐쉬되어지지 않는다.

* Video들은 스트리밍 되어진다.

PHImageManager

원하는 size기반의 image들을 요청할 수 있다.

사용법에 따라 video들을 요청할 수 있다.

비동기 API

선택적으로 network로 부터 data를 검색할 수 있다.

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 requestHandler: ^(UIImage *result, NSDictionary *info) {
 if(result) {
  [cell setImage: result];
 } else {
 }
}];
// 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 ….];

Image Request Callbacks

[manager requestImageForAsset: … ^(UIImage *result, NSDictionary *info) {
 // This block can be called multiple times
}];

Requesting Videos

// Request a playback item for video playback
[manager requestPlayerItemForVideo: video options: nil requestHandler: ^(AVPlayerItem *item, NSDictionary *info) {
 AVPlayer *player = [AVPlayer playerWithPlayerItem: playerItem];
}];

Advanced Video Requests

// 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 …];

Scrolling Performance

thumbnails의 grid 스크롤링

보여지는 범위에서 cache 유지

  • 스크롤 앞에서 캐싱 시작
  • 스크롤 뒤로 캐싱 중지

PHCachingImageManager

image들을 미리로드하고 캐쉬한다.

Caching image manager에 대한 요청

Request들은 cache된 data에 대해 해결된다.

각 view controller에 대한 instance

Preheating

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];
Editing Images and Videos

제자리에서

* 새로운 asset으로 저장하지 않아도 된다.

비파괴

어디에서나 볼 수 있다.

iCloud 사진 라이브러리를 통해 동기화 된다.

Editing Flow

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
}

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) { }

Resumable Edits

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;

Adjustment Data

PHContentEditingInputRequestOptions *options = …
// Do you understand the current adjustment
options.caHandleAdjustmentData: ^BOOL(PHAdjustmentData *adjustmentData)
{
return [adjustmentData.formatIdentifier isEqual: @“com.mycompany”]
&& [adjustmentData.formatVersion isEqual:@“1.0”];
}

Photo Editing Extensions

Image or video editor

내장된 Photos앱 및 Camera 앱으로 부터 이용할 수 있다.

What`s Needed

App extension target

UIViewController 상속

Protocol 채택

User Interface

Photos앱에 의해 보여지는 Navigation bar

우리의 extension에 기반한 navigation bar를 피해라.

Protocol Adoption

PHContentEditingController

startContentEditingWithInput:

finishContentEditingWithCompletionHandler:

canHandleAdjustmentData:

cancelContentEditing

Getting Input & Finish

- (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;
}
- (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);
}

Resuming Edits

- (BOOL)canHandleAdjustmentData: (PHAdjustmentData *)adjustmentData
{
return [adjustmentData.formatIdentifier isEqual: @“com.mycompany”]
&& [adjustmentData.formatVersion isEqual:@“1.0”];
}

Apple Photos앱 용어 정리

  • 표준 앨범: 이러한 앨범을 생성하고 이름을 지정한 후 원하는 사진 및 비디오 클립을 추가할 수 있습니다. 여러 앨범에 같은 사진을 포함시키고 앨범에서 언제든지 사진을 추가하거나 삭제할 수 있습니다.
  • 스마트 앨범: 스마트 앨범은 사용자가 지정한 기준에 따라 자동으로 사진을 수집하고 표시합니다. 예를 들어, 스마트 앨범을 생성하여 2014년에 찍은 모든 사진(즐겨찾는 사진이기도 한)을 포함하도록 설정할 수 있습니다. 그러면 사진 앱이 해당 기준에 맞는 사진을 스마트 앨범에 추가합니다. 새로운 사진을 가져올 때마다 사진 앱은 해당 기준에 맞는 사진을 스마트 앨범에 계속 추가합니다.
  • 폴더: 보관함을 추가로 구성하려면 폴더에 앨범을 그룹화하면 됩니다. 예를 들어, 가족 모임 앨범 또는 캠핑 여행 사진으로 된 앨범을 포함하는 폴더를 생성할 수 있습니다. 폴더 사용에 대한 추가 정보를 보려면 폴더에서 앨범 그룹화하기를 참조하십시오.

보관함을 정리된 상태로 유지하기 위해 사진 앱은 다음을 포함하여 자동으로 사용자의 앨범을 생성합니다.

  • 모든 사진: 보관함에 추가된 날짜별로 정렬된 보관함의 모든 사진을 포함합니다. 또한 이 앨범은 iCloud 사진 보관함이나 나의 사진 스트림이 켜져 있는 다른 iOS 기기와 Mac 컴퓨터에서 전송된 사진도 포함합니다.
  • 사람: 사람 사진을 포함합니다. 사진 앱은 보관함을 자동으로 스캔하고 얼굴 인식 기술을 사용하여 사진에 있는 사람들을 인식합니다. 인식된 사람에 이름을 지정하면 즐겨찾는 사람들의 사진을 쉽게 찾고 탐색할 수 있습니다.
  • 장소: 세계 지도에 사진을 축소판으로 표시할 수 있습니다. 사진 축소판을 클릭하여 해당 위치에서 찍은 사진을 볼 수 있습니다.
  • 즐겨찾는 추억: 즐겨찾는 추억으로 표시한 추억을 포함합니다.
  • 최근 가져온 항목: 가장 최근에 사진 보관함에 추가한 사진을 포함합니다. 이 앨범에 있는 사진은 사진을 가져올 때마다 업데이트됩니다. 이전에 가져온 사진은 더 이상 여기에 나타나지 않지만 전체 사진 앨범, 사진 앱의 보기 및 사진을 추가한 모든 앨범에서는 계속 볼 수 있습니다.
  • 선호하는 사진: 선호하는 사진으로 표시한 사진을 포함합니다.
  • 파노라마: 가져온 파노라마 사진을 포함합니다.
  • 비디오: 가져온 비디오를 포함합니다.
  • 슬로 모션: iOS 기기에서 가져온 슬로 모션 비디오를 포함합니다.
  • 타임랩스: iOS 기기에서 가져온 타임랩스 비디오를 포함합니다.
  • 고속 연사 촬영: iOS 기기에서 가져온 파노라마 사진을 포함합니다. 이 앨범을 열고 각 고속 연사 촬영 사진을 조사하여 최상의 이미지를 선택할 수 있습니다.
  • 나의 사진 스트림: 나의 사진 스트림에서 전송된 사진을 포함합니다. 이 앨범은 나의 사진 스트림을 켜고 iCloud 사진 보관함을 끄면 나타납니다.
  • 셀프 사진: iOS 기기의 전면 FaceTime 카메라로 촬영한 사진을 포함합니다. 사진 앱은 이 사진을 ‘셀프 사진’으로 가져오고 셀프 사진 앨범에 저장합니다.
  • 스크린샷: iOS 기기 화면의 스크린샷을 포함합니다(잠자기/깨우기 버튼 및 Home 버튼을 동시에 길게 눌려 촬영된).
  • iPhoto 이벤트: iPhoto 또는 Aperture 보관함을 사진 앱으로 업그레이드하면 각 iPhoto 이벤트 또는 Aperture 프로젝트의 사진 앨범을 포함합니다.
  • 최근 삭제된 항목: 사용자가 최근 삭제한 사진을 포함합니다. 영구적으로 삭제되기 전에 특정 기간 동안 삭제된 사진이 앨범에 남습니다. 이 앨범의 사진을 보관함에 복원하거나 즉시 영구적으로 삭제할 수 있습니다.
  • 가려짐: 가려진 사진을 포함합니다(사진 보관함에 남지만 보이지 않음). 가려진 앨범을 보려면 보기 > 가려진 사진 앨범 보기를 선택합니다.

Apple Document 정리

PHFetchResult

Photos framework의 fetch method로 부터 리턴된 assets or collections의 정렬된 리스트이다.

PHAsset, PHCollection, PHAssetCollection, PHAssetCollectionList 클래스들의 클래스 메소드를 사용하여 객체를 검색하면 Photos는 패치된 결과의 객체들을 제공합니다. NSArray 클래스에서 사용하는 것과 동일한 메서드 및 규칙을 사용하여 패치 결과의 내용에 액세스할 수 있습니다. NSArray와 달리 PHFetchResult객체는 필요에 따라 Photos framework에서 내용을 동적으로 로드하므로 많은 수의 결과를 처리할 때에도 최적의 성능을 제공합니다.

패치 결과는 패치 결과의 내용에 대한 안전한 쓰레드 액세스를 제공합니다. 패치 후 패치 결과의 갯수 값은 일정하며 패치 결과의 모든 객체는 동일한 로컬 식별자 값을 유지합니다.(패치에 대해 업데이트된 내용을 얻을려면 PHPhotoLibrary객체의 옵저버로 등록하십시오) 패치결과는 가장 최근에 액세스한 index 주의에 객체 배치를 유지하면서 내용을 캐시합니다. 배치 외부의 객체는 더 이상 캐시되지 않으므로 배치 외부의 객체에 액세스하게 되면 해당 객체가 다시 패치됩니다. 이 프로세스로 인해 이전에 해당 객체에서 읽은 값을 변경될 수 있습니다.

PHChange

Photos library에서 발생된 변경 사항에 대한 설명

Photos framework는 Photos앱에서 관리되는 assets, collections에 대한 변경사항에 대한 알림을 PHChange객체로 제공합니다. 변경 정보를 수신하려면 PHPhotoLibraryChangeObserver 프로토콜을 채택하고 옵저버를 PHPhotoLibrary객체에 등록하십시오.

Photos framework가 PHChange객체를 제공 후에, PHChange 객체의 메소드를 사용하여 변경 세부 객체를 가져옵니다. changeDetails(for:)를 호출하여 이전에 가져온 asset 또는 collection 객체를 전달하거나 이러한 객체가 여러개 포함된 패치 결과를 전달합니다. 결과로 생성된 PHObjectChangeDetails 또는 PHFetchResultChangeDetails 객체는 객체를 마지막으로 가져온 이후 객체 또는 패치 결과에서 발생한 모든 변경사항을 설명합니다.


반응형
Comments