When permission has been granted by the user, the enumerateAssetGroupsBlock block will be executed. The block will be executed on the main thread, but there is no guarantee when the block will be called since it might be waiting for permission. So any logic in that block needs to take that into consideration. The block signature accepts an instance of ALAssetsGroup and a pointer to a BOOL. If you want to immediately stop iterating, set the BOOL pointer stop to YES.

void (^enumerateAssetGroupsBlock)(ALAssetsGroup*, BOOL*) =^(ALAssetsGroup* group, BOOL* stop){    if (group)    {        ...    }    else    {        [self setAssetGroupArray:         [NSArray arrayWithArray:setupArray]];        [setupArray release ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.