Best way to sync iOS application with ALAssetsLibrary when app comes to foreground

alassetslibrary, ios, ios5

Solution

You should register for ALAssetsLibraryChangedNotification and only reenumerate the Library, when you receive the notification, that the Library has actually changed. You will receive this notification, when you app is in the foreground again. Please note that, there is a bug in iOS 5.X regarding ALAssetsLibraryChangedNotification: http://www.openradar.me/10484334

Cheers,

Hendrik

Problem

My application keeps a cache of ALAssets. The user may put the app into the background and then use the Photos app, or some other means, to delete some photos or videos. When my app is in the background, I do not get the notification from ALAssetsLibrary that data has changed. Does anyone have an optimal approach to syncing my application state with the ALAssetsLibrary state when the application becomes active again? Upate: It looks like I can use this approach to iterate back over the entire library, but it seems an inefficient way to get the delta of changes. How to check if an ALAsset still exists using a URL

Original source

Related problems