title: Get Image from URL and display them to Image Gallery AlAsset
body: <p>I know this question might be asked many time but i am a beginner so kindly being gentle is a humble request.</p>
  
  <p>I am trying to make an image gallery which displays all the images Of a URL.</p>
  
  <p>I have used all asset framework and made a simple gallery which return the images of camera roll, I want to have the image of some URL so kindly help me to Get images from url and display them to Image Gallery </p>
  
  <p>Here Is the view Controller header File</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;AssetsLibrary/AssetsLibrary.h&gt;
  
  @interface ViewController : UIViewController &lt;UICollectionViewDelegate,UICollectionViewDataSource&gt;
  @property (retain, nonatomic) IBOutlet UICollectionView *collectionView;
  @property(nonatomic, strong) NSArray *assets;
  </code></pre>
  
  <p>Here is the Implementation file In which I have registered An .NIB file to add Cell to my <code>CollectionView</code></p>
  
  <pre><code>#import "ViewController.h"
  #import &lt;AssetsLibrary/AssetsLibrary.h&gt;
  #import "MyCell.h"
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      [self.collectionView registerNib:[UINib nibWithNibName:@"MyCell" bundle:nil] forCellWithReuseIdentifier:@"CELL"];
  
  
  
  
  
  _assets = [@[] mutableCopy];
  __block NSMutableArray *tmpAssets = [@[] mutableCopy];
  // 1
  </code></pre>
  
  <p>here it is calliing <code>defaultAssetsLibrary</code> method which you can see later</p>
  
  <pre><code> ALAssetsLibrary *assetsLibrary = [ViewController defaultAssetsLibrary];
      // 2
      [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
          [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
  
  
    if(result)
              {
  
                  // 3
                  [tmpAssets addObject:result];
              }
          }];
  
          // 4
          //NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO];
          //self.assets = [tmpAssets sortedArrayUsingDescriptors:@[sort]];
          self.assets = tmpAssets;
  
          // 5
          [self.collectionView reloadData];
      } failureBlock:^(NSError *error) {
          NSLog(@"Error loading images %@", error);
      }];
  
  
  
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  #pragma mark - collection view data source
  
  
  - (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  {
      return self.assets.count;
  }
  
  // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
  
  
  
  - (MyCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
      MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];
  
      ALAsset *asset = self.assets[indexPath.row];
      cell.asset = asset;
      cell.backgroundColor = [UIColor redColor];
      ////
      //=
  
  
      cell.cellLabel.text = [NSString stringWithFormat:@"cell %i",indexPath.row];
      return cell;
  }
  
  - (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  {
      ALAsset *asset = self.assets[indexPath.row];
      ALAssetRepresentation *defaultRep = [asset defaultRepresentation];
      UIImage *image = [UIImage imageWithCGImage:[defaultRep fullScreenImage] scale:[defaultRep scale] orientation:0];
  
      // Do something with the image
  
  }
  </code></pre>
  
  <p>And here is that method which I think returning the photo library</p>
  
  <pre><code>+ (ALAssetsLibrary *)defaultAssetsLibrary
  {
  
  
      static dispatch_once_t pred = 0;
      static ALAssetsLibrary *library = nil;
      dispatch_once(&amp;pred, ^{
          library = [[ALAssetsLibrary alloc] init];
      });
      return library;
  }
  </code></pre>
  
  <p>Please Help me to get Images From URL and display them in Image Gallery.</p>
  
  <p>As Far as MyCell file is concern.</p>
  
  <p>Here is MYCell.m file</p>
  
  <pre><code>@interface MyCell ()
  // 1
  @property(nonatomic, strong) IBOutlet UIImageView *photoImageView;
  @end
  
  @implementation MyCell
  
  - (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
          // Initialization code
      }
      return self;
  }
  
  - (void) setAsset:(ALAsset *)asset
  {
  
  
      // 2
      _asset = asset;
      self.photoImageView.image = [UIImage imageWithCGImage:[asset thumbnail]];
      }
  </code></pre>