Advertisement
Guest User

Implementaion Class

a guest
Jul 20th, 2012
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface NSOperationalQueueViewController : UIViewController {
  4.    
  5.     NSMutableArray *urlArray;
  6.     NSOperationQueue *operationQueue;
  7. }
  8.  
  9. +(id)getParent;
  10.  
  11. @end
  12.  
  13.  
  14.  
  15. #import "NSOperationalQueueViewController.h"
  16. #import <AssetsLibrary/AssetsLibrary.h>
  17. #import "DisplayImages.h"
  18.  
  19. @implementation NSOperationalQueueViewController
  20.  
  21. - (void)viewDidLoad {
  22.    
  23.     urlArray = [[NSMutableArray alloc] init];
  24.    
  25.     void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop){
  26.    
  27.         if(result != NULL){
  28.                    
  29.             NSURL *url = [[result defaultRepresentation] url];
  30.             [urlArray addObject:url];              
  31.         }
  32.     };
  33.    
  34.     void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop) {
  35.        
  36.         if(group != nil){
  37.        
  38.             [group enumerateAssetsUsingBlock:assetEnumerator];
  39.         }
  40.         else{      
  41.             operationQueue = [[NSOperationQueue alloc] init];
  42.            
  43.             float Xcord = 10.0;
  44.            
  45.             float yCord = 5.0;
  46.            
  47.         for (int index = 0; index < 8; index++){               
  48.                
  49.         if (index != 0)
  50.             Xcord = Xcord + (index * 10) + 50 ;            
  51.                
  52.                
  53.                 UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(Xcord,yCord, 50, 50)];
  54.                 [imageView setBackgroundColor:[UIColor blueColor]];
  55.                 [self.view addSubview:imageView];
  56.                
  57.                 NSURL *imageUrl = [urlArray objectAtIndex:index];
  58.                
  59.                 DisplayImages *displayImages = [[DisplayImages alloc] initWithAttributes:imageUrl ImageView:imageView];
  60.                 [operationQueue addOperation:displayImages];
  61.                 [displayImages release];               
  62.                
  63.                 [imageView release];               
  64.                 imageView = nil;               
  65.             }          
  66.         }      
  67.     };
  68.    
  69.     ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
  70.     [assetslibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:assetGroupEnumerator failureBlock: ^(NSError *error) {
  71.                                  
  72.         NSLog(@"Failure");
  73.                                    
  74.    }];
  75.    
  76.     [super viewDidLoad];
  77. }
  78.  
  79.  
  80. +(id)getParent{
  81.    
  82.     return self
  83. }
  84.  
  85. - (void)dealloc {
  86.    
  87.     [urlArray release];
  88.     urlArray = nil;
  89.  
  90.         [super dealloc];
  91. }
  92.  
  93. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement