简体   繁体   中英

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

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.

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

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