How can I get my alassets from my library in date order across all photo albums?

不想你离开。 提交于 2019-12-12 01:25:41

问题


I've been looking around and have only found answers in pulling out assets in groups. What I want to do is get all the image/photo data from my iPhone/iPad not grouped by album (ie Camera Roll, custom folders, etc) but just by date. I don't see any examples here or on Apple docs on how to just say "Give me all my assets but use this predicate to sort them" Everything I've seen uses the enumerator to return the results by groups. Setting the group setting to "ALL" just returns the assets in group order and then sort them how I want.

Is this just not possible? I'm hitting another problem with performance but I think I can solve that if I can guarantee that the assets are sorted by date.


回答1:


There is no way to get ALL the assets at once; they're always grouped by album.

You could iterate through every album, add all the assets to an NSMutableArray, and sort that array using a custom NSComparator.

I have created a database of ALAssets, based on CoreData, that allows you to search all the assets using predicates. The problem with the ALAssetsLibrary, however, is that it is extremely slow to index every ALAsset in a database.

Check out the LLAssetsDatabase on Github: http://github.com/Glnn/LLAssetDatabase



来源:https://stackoverflow.com/questions/11622389/how-can-i-get-my-alassets-from-my-library-in-date-order-across-all-photo-albums

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!