How can I verify that ALAsset is an image. How can I separate image files (.png) from ALAssetGroup

How can I verify that ALAset is an image? How can I separate image files (.png) from ALAssetGroup.can can I only extract image files (.png) from iphone Photo libaray?

+4
source share
2 answers

First of all, you need to list the entire AssetGroup. Then check each asset for 2 things:

1) To check if the object is an image, a request

[[asset valueForProperty:@"ALAssetPropertyType"] isEqualToString:@"ALAssetTypePhoto"] 

2) if 1) is true, then continue checking if it's PNG, like this:

 [[[asset defaultRepresentation] UTI] isEqualToString:@"public.png"] 
+15
source

Without using NSString:

[[asset valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypeVideo]

+5
source

Source: https://habr.com/ru/post/1347948/


All Articles