iosobjective-cphotosphotokit

How to know if a PHAsset has been modified?


More specifically, how can you know whether a PHAsset has current version of the underlying asset different than the original?

My user should only need to choose between the current or original asset when necessary. And then I need their answer for PHImageRequestOptions.version.


Solution

  • As of iOS 16, PHAsset has a hasAdjustments property which indicates if the asset has been edited.

    For previous releases, you can get an array of data resources for a given asset via PHAssetResource API - it will have an adjustment data resource if that asset has been edited.

    let isEdited = PHAssetResource.assetResources(for: asset).contains(where: { $0.type == .adjustmentData })
    

    Note that if you want to actually work with a resource file, you have to fetch its data using a PHAssetResourceManager API. Also note that this method returns right away - there's no waiting for an async network request, unlike other answers here.