我可以将自定义元数据与 ALAsset 关联吗?
我正在构建一个 iPhone 应用程序,除其他外,它允许用户拍摄和存储与位置相关的照片。我目前正在使用 ALAssetLibrary 来允许照片存储在照片中,并可以在应用程序外部访问(例如通过内置机制在计算机上)。使用 ALAssetLibrary 的技术内容并不多,但我已经设法拼凑出一个工作版本。我不得不在我的应用程序中存储照片 URL 的字典,并在显示照片列表时手动检测照片是否仍然存在,因为似乎没有办法将自定义元数据添加到 ALAsset。
我真正想做的是向每个资产添加两个自定义元数据字段,为其提供标题和自定义 id 值,我可以在枚举资产库时使用它们进行过滤。
作为次要任务,我希望用户能够更新标题元数据。
能做到吗?在这一点上,我真的不认为可以,因为 API 似乎确实没有提供获取/设置自定义元数据的必要方法。尽管困难重重,我还是希望 AssetLibrary 框架还有一些我尚未发现的方面。
至少,如果有人可以权威地说“不”,那么至少其他人可能会在自己的希望之路上找到这个面包屑,并更快地改变策略!
而且,拥有 0 声誉,我无法用 AssetLibrary 标记它:( 哇,这一天正在走下坡路。FML
I'm building an iPhone app that, among other things, allows the user to take and store photographs associated with locations. I am currently using the ALAssetLibrary to allow the photographs to be stored in Photos and be accessible outside the app (on a computer for instance via the built-in mechanisms). There is not a lot of technical content out there for working with the ALAssetLibrary but from what there is I have managed to cobble together a working version of this. I have had to resort to storing a dictionary of photo URLS in my app and manually detecting if the photo still exists when displaying lists of them because there does not seem to be a way to add custom metadata to an ALAsset.
What I would really like to do is add two custom metadata fields to each asset to provide it with a title and a custom id value that I can use to filter on when enumerating the asset library.
As a secondary task, I'd like the user to be able to update the title metadata.
Can it be done? At this point, I really don't think it can because the API really doesn't seem to provide the necessary methods to get/set custom metadata. I'm hoping against all odds that there is some other aspect to the AssetLibrary framework that I have not yet discovered.
At a minimum, if someone can authoritatively say "NO" then at least others might find this breadcrumb on their own trail of hope and change tack more quickly!
And, having 0 reputation I can't tag it with AssetLibrary :( wow, this day is just going downhill. FML
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在查看文档,我认为不可能向 ALAsset 对象附加其他字段,您可以创建自己的对象或扩展它们的对象,但这在您撤回资产时不会有帮助,因为您需要然后初始化你的并填充它。
听着,我知道这不是一个很好的答案,但我必须尝试。
I've been looking over the documentation and I dont think it is possible to tack on additional fields to the ALAsset object, well you can create your own object or extend theirs but that wont help you when your pulling back assets because you'll need to init yours and populate it then.
Look I know this falls short of a really good answer but I had to try.
ALAsset 类文档描述了一个属性 - customMetadata。这被记录为您想要的任何自定义标签的 NSDictionary。然而,目前它还没有在类中实现(我已经在苹果的开发者网站上提出了一个错误来提出这个问题)。
The ALAsset class documentation describes a property - customMetadata. This is documented to be an NSDictionary of whatever custom tags you want. Currently, however, it is not implemented in the class (I've raised a bug on Apple's developer site to bring the issue up).