ALAssetsGroup 无效
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为 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.