Skip to content

Instantly share code, notes, and snippets.

@sprite2005
Created July 7, 2011 02:31
Show Gist options
  • Save sprite2005/1068798 to your computer and use it in GitHub Desktop.
Save sprite2005/1068798 to your computer and use it in GitHub Desktop.
- (IBAction) quickImport
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSMutableArray* assets = [[NSMutableArray alloc] init];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result) {
[assets addObject:result];
}
}];
ALAsset* lastAsset = [assets lastObject];
ALAssetRepresentation* representation = [lastAsset defaultRepresentation];
CGImageRef imageRef = [representation fullResolutionImage];
if (imageRef) {
UIImage* image = [UIImage imageWithCGImage:imageRef];
[self performOCROnImage:image withAnalysis:YES];
}
[assets release];
} failureBlock:^(NSError *error) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:@"To use this feature, please enable Location Services. To do so, go to Settings -> Location Services and turn it on for Word Cheat." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}];
[library release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment