Register an observer to be notified of changes to the photo library.
To be notified of changes to the photo library, use the
register(_:) method to designate an observer object. Whenever you use a fetch method, such as
fetch, to retrieve assets or collections, Photos automatically registers your interest in observing changes to those items. After you perform a fetch, Photos sends messages to your observer through the
PHPhoto protocol whenever the items in the resulting fetch request change. For example, you'll get notified when changes add items, remove items, or reorder the list of items in the fetch result. Update your user interface based on the details you receive from
Use the shared
PHPhoto object to register a change handler for the assets and collections you fetch. Photos tells your app whenever another app or device changes the content or metadata of an asset or the list of assets in a collection.
PHChange objects provide information about object state before and after each change with semantics that make it easy to update a collection view or similar interface.
For information about handling changes, see the