Skip to content

Instantly share code, notes, and snippets.

@miketihonchik
Created August 14, 2013 13:52
Show Gist options
  • Save miketihonchik/6231271 to your computer and use it in GitHub Desktop.
Save miketihonchik/6231271 to your computer and use it in GitHub Desktop.
sample functions calls to get the images from the iPhone image library
#import <AssetsLibrary/AssetsLibrary.h>
- (void)viewDidLoad
{
[super viewDidLoad];
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if( result != nil)
{
[_assets addObject:result];
}
};
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if( group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
_assets = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [CustomCameraViewController defaultAssetsLibrary];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:assetGroupEnumerator failureBlock:^(NSError *error) {
NSLog(@"Problem!");
}];
}
+ (ALAssetsLibrary *)defaultAssetsLibrary {
static dispatch_once_t pred = 0;
static ALAssetsLibrary *library = nil;
dispatch_once(&pred, ^{
library = [[ALAssetsLibrary alloc] init];
});
return library;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment