Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- @interface DisplayImages : NSOperation {
- NSURL *imageUrl;
- UIImageView *imageView;
- }
- @property (nonatomic,retain) NSURL *imageUrl;
- @property (nonatomic,retain) UIImageView *imageView;
- -(id)initWithAttributes:(NSURL *)imageUrlFromMain ImageView:(UIImageView *)imageViewFromParent;
- @end
- #import "DisplayImages.h"
- #import <AssetsLibrary/AssetsLibrary.h>
- #import "NSOperationalQueueViewController.h"
- @implementation DisplayImages
- @synthesize imageUrl;
- @synthesize imageView;
- -(id)initWithAttributes:(NSURL *)imageUrlFromMain ImageView:(UIImageView *)imageViewFromParent{
- if (![super init]) return nil;
- [self setImageUrl:imageUrlFromMain];
- [self setImageView:imageViewFromParent];
- return self;
- }
- -(void)main{
- typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
- typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
- ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){
- ALAssetRepresentation *rep = [myasset defaultRepresentation];
- CGImageRef iref = [rep fullResolutionImage];
- UIImage *topicImage;
- if (iref){
- topicImage = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
- self.imageView.image = topicImage;
- //NSOperationalQueueViewController *temp = (NSOperationalQueueViewController *)[NSOperationalQueueViewController getParent];
- //[temp performSelectorOnMainThread:@selector(displayImages:) withObject:self.imageView waitUntilDone:YES];
- }
- };
- ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror){
- };
- NSLog(@"Url is %@",(NSString *)imageUrl);
- ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
- [assetslibrary assetForURL:imageUrl
- resultBlock:resultblock
- failureBlock:failureblock];
- }
- -(void)dealloc{
- [imageUrl release];
- imageUrl = nil;
- [imageView release];
- imageView = nil;
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement