Created
August 14, 2013 13:52
-
-
Save miketihonchik/6231271 to your computer and use it in GitHub Desktop.
sample functions calls to get the images from the iPhone image library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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