简体   繁体   中英

What is the difference between ALAsset and PHAsset?

I've been curious this morning about PHAsset . I used to deal with ALAsset last month. I downloaded an iOS project from Apple website that uses ALAsset to make a simple iOS Photos-like app, and I modified it to add more features to be more iOS Photos-like app. And then my boss handled my project and told the whole office that I should be trained and he has to re-write the whole project because my codes are mostly outdated (probably because of using ALAsset ?). My boss is so good in iOS and I saw his codes, he is using PHAsset .

So what is the difference between ALAsset and PHAsset ? I also saw a thread in Apple/iOS forum that PHAsset is new and ALAsset is old.

Also, I would like to know which is better between the two, and which of these two is easier to use when it comes to writing meta data to the image.

I am new to iOS (2 months), and I can see that PHAsset and ALAsset are both from NSObject .

https://developer.apple.com/library/prerelease/ios/documentation/Photos/Reference/PHAsset_Class/index.html

https://developer.apple.com/library/prerelease/ios/documentation/AssetsLibrary/Reference/ALAsset_Class/index.html

As you can see from the reference documentation for the two classes they are from two different frameworks.

PHAsset is from the newer Photos framework (added in iOS 8.0).

ALAsset is from the original AssetsLibrary framework.

You should use the newer framework if your app's Deployment Target is iOS 8.0 or newer. Only use the older AssetsLibrary framework if your app has a need to support iOS 7 or earlier.

The question of which is easier is irrelevant in this case. Use the newer one if possible. Apple always encourages the use of the newest frameworks, libraries, OS, hardware, etc.

You will also notice that the entire AssetsLibrary framework has been deprecated. This means it is obsolete. It still functions but its use is discouraged in favor of the newer library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM