Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <UIKit/UIKit.h>
- @interface NSOperationalQueueViewController : UIViewController {
- NSMutableArray *urlArray;
- NSOperationQueue *operationQueue;
- }
- +(id)getParent;
- @end
- #import "NSOperationalQueueViewController.h"
- #import <AssetsLibrary/AssetsLibrary.h>
- #import "DisplayImages.h"
- @implementation NSOperationalQueueViewController
- - (void)viewDidLoad {
- urlArray = [[NSMutableArray alloc] init];
- void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop){
- if(result != NULL){
- NSURL *url = [[result defaultRepresentation] url];
- [urlArray addObject:url];
- }
- };
- void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
- if(group != nil){
- [group enumerateAssetsUsingBlock:assetEnumerator];
- }
- else{
- operationQueue = [[NSOperationQueue alloc] init];
- float Xcord = 10.0;
- float yCord = 5.0;
- for (int index = 0; index < 8; index++){
- if (index != 0)
- Xcord = Xcord + (index * 10) + 50 ;
- UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(Xcord,yCord, 50, 50)];
- [imageView setBackgroundColor:[UIColor blueColor]];
- [self.view addSubview:imageView];
- NSURL *imageUrl = [urlArray objectAtIndex:index];
- DisplayImages *displayImages = [[DisplayImages alloc] initWithAttributes:imageUrl ImageView:imageView];
- [operationQueue addOperation:displayImages];
- [displayImages release];
- [imageView release];
- imageView = nil;
- }
- }
- };
- ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
- [assetslibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:assetGroupEnumerator failureBlock: ^(NSError *error) {
- NSLog(@"Failure");
- }];
- [super viewDidLoad];
- }
- +(id)getParent{
- return self
- }
- - (void)dealloc {
- [urlArray release];
- urlArray = nil;
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement