0

I have a collection view with many pictures from Facebook.

It takes alot of time for the collection to load & show the pictures.

How can I show the pictures one by one without waiting for the end of the process?

This is my code:

-(void)viewDidAppear:(BOOL)animated
{
    NSMutableArray *jpegFiles = [[NSMutableArray alloc]init];

    NSMutableArray *picsArr =[[NSMutableArray alloc] initWithArray:[LocalUser sharedUser].profilePics];

    for(NSString *picLink in picsArr)
    {
        [jpegFiles addObject:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picLink]]]];
        self.dataArray = jpegFiles;
        [self.collectionView reloadData];
    }
}
Asi Givati
  • 1,348
  • 1
  • 15
  • 31

1 Answers1

1

Look at SDWebImage. It'll handle all the asynchronous loading of the images from the web.

Lance
  • 8,872
  • 2
  • 36
  • 47
  • SDWebImage is great, but you can also look at [AFNetworking](https://github.com/AFNetworking/AFNetworking) if you need to load other data as well. It is an extremely powerful networking library that makes loading data/images much easier. – mrosales Mar 31 '14 at 16:39
  • Agreed! However, AFNetworking is a little large if all you want is asynchronous images which is why I suggested SDWebImage – Lance Mar 31 '14 at 17:09
  • great, thanks! Can you be a bit more specific and direct me what file I'm supposed to use of all this project? – Asi Givati Apr 01 '14 at 04:59