简体   繁体   English

如何在所有相册中按日期顺序从媒体库中获取我的曲调集?

[英]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. 我要做的是从iPhone / iPad中获取所有图像/照片数据,而不是按相册(即相机胶卷,自定义文件夹等)分组,而仅按日期分组。 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. 在这里或Apple文档上,我没有看到任何有关如何只说“给我所有资产,但使用此谓词对它们进行排序”的示例。我所看到的所有内容都使用枚举器按组返回结果。 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. 您可以遍历每张专辑,将所有资产添加到NSMutableArray,然后使用自定义NSComparator对数组进行排序。

I have created a database of ALAssets, based on CoreData, that allows you to search all the assets using predicates. 我创建了一个基于CoreData的ALAssets数据库,该数据库使您可以使用谓词搜索所有资产。 The problem with the ALAssetsLibrary, however, is that it is extremely slow to index every ALAsset in a database. 但是,ALAssetsLibrary的问题在于,索引数据库中的每个ALAsset非常慢。

Check out the LLAssetsDatabase on Github: http://github.com/Glnn/LLAssetDatabase 在Github上查看LLAssetsDatabase: http ://github.com/Glnn/LLAssetDatabase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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