ALAssetsGroup 无效

发布于 2024-12-12 09:58:34 字数 507 浏览 1 评论 0原文

我正在使用 AssetsLibrary 框架将资源保存到特定相册 (ALAssetsGroup)。

由于我经常使用 ALAssetsGroup (对于我想要保存资源的相册),我认为保留它是明智的,所以我不必(异步)迭代每次我需要的时候都通过小组。

检索/创建相册时,所有内容都会正确显示(对于 valueForProperty:),但该组似乎会在一段时间后自行失效,并且其所有属性都将返回 nil。另外, addAsset: 不起作用,所以我必须再次搜索相册(这次是通过 URL 搜索,但仍然是异步的)。

有没有办法解决这个问题(保持 ALAssetsGroup 有效)?

iOS 5 上发生了这种情况,并且库 (ALAssetsLibrary) 也被保留。 我正在使用设置器来确保我不会自己重置

I'm using AssetsLibrary framework for saving assets to a specific album (ALAssetsGroup).

Since I'm using the ALAssetsGroup (for the album where I want to save the assets) quite often, I figured it would be wise to retain it, so I don't have to iterate (asynchronously) through the groups each time I need it.

When retrieving/creating the album everything shows up correctly (for valueForProperty:), but the group seems to invalidate itself after some time, and all its properties will return nil. Also, addAsset: won't work on it, so I have to search for the album again (this time it's searched by its URL, but it's still asynchronous).

Is there a way around this (to keep the ALAssetsGroup valid)?

This is happening on iOS 5, and the library (ALAssetsLibrary) is retained as well.
I am using a setter to make sure that I don't reset the group myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余厌 2024-12-19 09:58:34

您需要为 ALAssetsLibrary 的 ALAssetsLibraryChangedNotification 添加观察者,并在收到它后重新查询任何缓存的 AL* 对象。这将在出售的 AL* 对象失效之前立即发布。

You need to add an observer for the ALAssetsLibraryChangedNotification for your ALAssetsLibrary and upon receiving it re-query for any of your cached AL* objects. That will be posted immediately before the vended AL* objects become invalid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文