alex-i
alex-i

Reputation: 5454

ALAssetsGroup becomes invalid

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.

Upvotes: 4

Views: 1681

Answers (1)

Ashley Clark
Ashley Clark

Reputation: 8823

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.

Upvotes: 4

Related Questions