What's difference between NSPhotoLibraryAddUsa

2019-01-26 02:47发布

My app get crashed today while updating on Xcode9, testing on iOS11. After adding NSPhotoLibraryAddUsageDescription then it works, even i already had NSPhotoLibraryUsageDescription.

Ive read about them, one supported since iOS6, one iOS11 but Apple didn't mention what's difference between them. https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73

If i keep the new one (NSPhotoLibraryAddUsageDescription), will it work for iOS 8 also or i have to keep both of them?

5条回答
女痞
2楼-- · 2019-01-26 03:25

Simple get from Apple Official Document

Just click on above image for ZOOM and read it.

For more information on:

查看更多
虎瘦雄心在
3楼-- · 2019-01-26 03:28

To answer the last question on my own:

You need to declare both NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription to get it WORKS on both iOS 9, 10.3 and 11.

Technically it's different. I used to not declare NSPhotoLibraryUsageDescription, it works fine on iOS 9 and 11 but failed and crashed on iOS 10.3.

This is a really bad version controlling from Apple while higher version doesn't comply and support older version permission.

查看更多
别忘想泡老子
4楼-- · 2019-01-26 03:32

There is a difference for write access based on the API asking for permission as well as the iOS version, so you need both.

My app already had NSPhotoLibraryUsageDescription in order to use PHPhotoLibrary to save images.

On iOS 11, that still works but if my app hasn't yet got permission then sharing an image via "Save Image" in a UIDocumentInteractionController causes a crash with a warning about NSPhotoLibraryAddUsageDescription. If permission has already been granted via PHPhotoLibrary I don't seem to need NSPhotoLibraryAddUsageDescription for "Save Image".

查看更多
Bombasti
5楼-- · 2019-01-26 03:48

As I can see in the document, the difference between two is:

  • NSPhotoLibraryAddUsageDescription: You have permission to write only, no read.

  • NSPhotoLibraryUsageDescription: You can both read and write to Photos.

From Apple documentations for NSPhotoLibraryUsageDescription:

"Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets."

查看更多
甜甜的少女心
6楼-- · 2019-01-26 03:51

You gonna need both.
Because once I tried use UIActivityViewController to save image to library, my iphone version is 11.3, I only use NSPhotoLibraryUsageDescription and it's crash because i need NSPhotoLibraryAddUsageDescription.
But ios 9.3 not crash.

查看更多
登录 后发表回答