PHAsset is a class for fetching metadata about media that is located in your Photo Library. So if you are making an app to pin point all the locations of your favourite photos on a map, then you would use PHAsset to extract this data.
PHAsset is part of the Photos framework, which replaced AssetsLibrary from iOS 9.0 onwards. So remember to import Photos to your code. The first thing you need to do is to fetch the asset or assets. You can choose between either collecting one asset (photo or video), an collection of them, all assets of a certain media type or a media with a certain identifier or URL. It is important to remember that this class won’t fetch the actual media (photo, video, audio), but the metadata of the media. After you them fetched the assets you can either gather metadata about them to use or you can also edit the metadata or the assets. So what data can you actually get after you have fetched the asset(s). Here is a quick list:
I previously wrote a tutorial on “How to read iOS Documentation” and there I used an example with fetching location and modificationDate from a older photo. Take a look at that here and see how you can fetch the metadata of an asset. I’ll also copy in a screenshot of my code that I used. This assumes that you have already chosen if you want to grab the picture from the Photo Library or if you want to take a new picture (hence the if else statement). Comments are closed.
|
Archives
April 2016
Categories
All
|