PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 12, 2022

[FIXED] How to know if a PHAsset has been modified?

 April 12, 2022     ios, objective-c, photokit, photos     No comments   

Issue

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

I have found a way to determine whether a PHAsset has been edited or not. Using a PHAssetResource API, you can get an array of data resources for a given asset. If the photo has been modified, it will have at least one resource that is the adjustment data of an edit.

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.



Answered By - Jordan H
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing