iOS 4 Assets Libraries problem: NSMutableArray contains data in Block, but is empty after Block calls
I'm trying to incorporate the example found on http://www.icodeblog.com/asset-libraries-and-blocks-in-ios-4/ into my own app.  This is what I have so far:

    @interface UserTabBarController : UIViewController <NSFetchedResultsControllerDelegate, UITabBarDelegate> {
        NSMutableArray *assets;
    }
        -(void)usingAssets;
    @end

    @implementation UserTabBarController
        -(void)usingAssets{
        	
            void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        	    if(result != NULL) {
        		NSLog(@"See Asset: %@", result);
        		[assets addObject:result];
        		NSLog(@"assets count: %i", assets.count);
        	    }
        	    else {
        		NSLog(@"AssetEnum: result nil or end of list");
        	    }
            };
        
            void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop) {
    	    if(group != nil) {
        		[group enumerateAssetsUsingBlock:assetEnumerator];
        	    }
        	    else {
        		NSLog(@"GroupEnum: group nil or end of list");
        	    }
        	    NSLog(@"assets count in GroupEnum: %i", assets.count);
        };
        	
        	
        	ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
        	
        	[library enumerateGroupsWithTypes:ALAssetsGroupAll
        						   usingBlock:assetGroupEnumerator
        							failureBlock: ^(NSError *error) {
        			   NSLog(@"Failure: %@", error.description);
        		}];
        	[library release];
        }


Let's (hopefully) agree that everytime I call usingAssets, I add the latest content of the Photo album to the `NSMutableArray* assets`.  I pull all this together in my ViewController's ViewDidLoad:

    - (void)viewDidLoad {
        [super viewDidLoad];
        assets = [[NSMutableArray alloc] init];
        [self usingAssets];
        for (ALAsset* a in self.assets){
    	    NSLog(@"Item in asset");
        }
        NSLog(@"Asset count: %i", assets.count);

        [self usingAssets];
        NSLog(@"Asset count: %i", assets.count);

    }

So far, I believe I've followed the example shown in the link above.
The problem is that within the scope of UserTabBarController, <code>assets.count</code> remains at 0, while within the scope of the Block, it shows the count as increasing, and it persists between both calls (as I would have expected). What I also find strange is that the lines Asset count: 0, should be appearing much later in the log, or maybe the lines of seeing assets (which are called from within the block) should be happening sooner:

2011-02-21 14:22:59.140 iPCS[7219:207] Asset count: 0  
2011-02-21 14:23:08.539 iPCS[7219:207] Asset count: 0  

2011-02-21 14:14:03.363 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG";
}  
2011-02-21 14:14:03.363 iPCS[7139:207] assets count: 1

2011-02-21 14:14:03.365 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000002&ext=JPG";
}  
2011-02-21 14:14:03.366 iPCS[7139:207] assets count: 2

2011-02-21 14:14:03.367 iPCS[7139:207] AssetEnum: result nil or end of list  
2011-02-21 14:14:03.367 iPCS[7139:207] assets count in GroupEnum: 2  
2011-02-21 14:14:03.368 iPCS[7139:207] GroupEnum: group nil or end of list  
2011-02-21 14:14:03.368 iPCS[7139:207] assets count in GroupEnum: 2  

2011-02-21 14:14:03.370 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG";
}  
2011-02-21 14:14:03.371 iPCS[7139:207] assets count: 3

2011-02-21 14:14:03.373 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000002&ext=JPG";
}  
2011-02-21 14:14:03.374 iPCS[7139:207] assets count: 4

2011-02-21 14:14:03.374 iPCS[7139:207] AssetEnum: result nil or end of list  
2011-02-21 14:14:03.375 iPCS[7139:207] assets count in GroupEnum: 4  
2011-02-21 14:14:03.375 iPCS[7139:207] GroupEnum: group nil or end of list  
2011-02-21 14:14:03.376 iPCS[7139:207] assets count in GroupEnum: 4  

What say you all?

iOS 4 Assets Libraries problem: NSMutableArray contains data in Block, but is empty after Block calls
===

I'm trying to incorporate the example found on http://www.icodeblog.com/asset-libraries-and-blocks-in-ios-4/ into my own app.  This is what I have so far:

    @interface UserTabBarController : UIViewController <NSFetchedResultsControllerDelegate, UITabBarDelegate> {
        NSMutableArray *assets;
    }
        -(void)usingAssets;
    @end

    @implementation UserTabBarController
        -(void)usingAssets{
        	
            void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        	    if(result != NULL) {
        		NSLog(@"See Asset: %@", result);
        		[assets addObject:result];
        		NSLog(@"assets count: %i", assets.count);
        	    }
        	    else {
        		NSLog(@"AssetEnum: result nil or end of list");
        	    }
            };
        
            void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop) {
    	    if(group != nil) {
        		[group enumerateAssetsUsingBlock:assetEnumerator];
        	    }
        	    else {
        		NSLog(@"GroupEnum: group nil or end of list");
        	    }
        	    NSLog(@"assets count in GroupEnum: %i", assets.count);
        };
        	
        	
        	ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
        	
        	[library enumerateGroupsWithTypes:ALAssetsGroupAll
        						   usingBlock:assetGroupEnumerator
        							failureBlock: ^(NSError *error) {
        			   NSLog(@"Failure: %@", error.description);
        		}];
        	[library release];
        }


Let's (hopefully) agree that everytime I call usingAssets, I add the latest content of the Photo album to the `NSMutableArray* assets`.  I pull all this together in my ViewController's ViewDidLoad:

    - (void)viewDidLoad {
        [super viewDidLoad];
        assets = [[NSMutableArray alloc] init];
        [self usingAssets];
        for (ALAsset* a in self.assets){
    	    NSLog(@"Item in asset");
        }
        NSLog(@"Asset count: %i", assets.count);

        [self usingAssets];
        NSLog(@"Asset count: %i", assets.count);

    }

So far, I believe I've followed the example shown in the link above.
The problem is that within the scope of UserTabBarController, <code>assets.count</code> remains at 0, while within the scope of the Block, it shows the count as increasing, and it persists between both calls (as I would have expected). What I also find strange is that the lines Asset count: 0, should be appearing much later in the log, or maybe the lines of seeing assets (which are called from within the block) should be happening sooner:

2011-02-21 14:22:59.140 iPCS[7219:207] Asset count: 0  
2011-02-21 14:23:08.539 iPCS[7219:207] Asset count: 0  

2011-02-21 14:14:03.363 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG";
}  
2011-02-21 14:14:03.363 iPCS[7139:207] assets count: 1

2011-02-21 14:14:03.365 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000002&ext=JPG";
}  
2011-02-21 14:14:03.366 iPCS[7139:207] assets count: 2

2011-02-21 14:14:03.367 iPCS[7139:207] AssetEnum: result nil or end of list  
2011-02-21 14:14:03.367 iPCS[7139:207] assets count in GroupEnum: 2  
2011-02-21 14:14:03.368 iPCS[7139:207] GroupEnum: group nil or end of list  
2011-02-21 14:14:03.368 iPCS[7139:207] assets count in GroupEnum: 2  

2011-02-21 14:14:03.370 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG";
}  
2011-02-21 14:14:03.371 iPCS[7139:207] assets count: 3

2011-02-21 14:14:03.373 iPCS[7139:207] See Asset: ALAsset - Type:Photo, URLs:{
    "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000002&ext=JPG";
}  
2011-02-21 14:14:03.374 iPCS[7139:207] assets count: 4

2011-02-21 14:14:03.374 iPCS[7139:207] AssetEnum: result nil or end of list  
2011-02-21 14:14:03.375 iPCS[7139:207] assets count in GroupEnum: 4  
2011-02-21 14:14:03.375 iPCS[7139:207] GroupEnum: group nil or end of list  
2011-02-21 14:14:03.376 iPCS[7139:207] assets count in GroupEnum: 4  

What say you all?
