Created
March 14, 2012 16:42
-
-
Save markdarling/2037771 to your computer and use it in GitHub Desktop.
Get Last Photo from Camera Roll
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
- (void)getLatestPhoto { | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { | |
[group setAssetsFilter:[ALAssetsFilter allPhotos]]; | |
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:[group numberOfAssets]-1] options:0 usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) { | |
if (alAsset) { | |
ALAssetRepresentation *representation = [alAsset defaultRepresentation]; | |
UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullResolutionImage]]; | |
// Got the lastestPhoto | |
} | |
}]; | |
} | |
failureBlock: ^(NSError *error) { | |
NSLog(@"Error"); | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment