-1

This is the code which I have done so far:

[userpic sd_setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"blackSquare.png"] options:SDWebImageProgressiveDownload]; 
Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Balaji Gupta
  • 33
  • 1
  • 12
  • 1
    Your question is a bit unclear. Do you have some performance problems? Please add details, what library do you use for image loading? – Daniyar Dec 23 '15 at 10:36

2 Answers2

1

Below my code which little bit fast i feel. check with one. I am using Afnetwork

#import "UIImageView+AFNetworking.h"  

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large",[[NSUSER objectForKey:@"user_info"] objectForKey:@"id"]]];
UIImage *pImage=[UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
_prof_pic_imageview.image=pImage;
Gaëtan Maisse
  • 12,208
  • 9
  • 44
  • 47
S. Karthik
  • 618
  • 5
  • 16
  • yes it will load faster nut what about the cache? Every time you want load image will request server for data, SDWeb image will kill image data in cache and on next request will fetch you data from cache and that will save your time and Mobile Data too... – Devang Tandel Dec 31 '15 at 12:39
1

I recommend to use SDWebImage instead..the method by @S.Karthik is good but will consume much more memory and will create View lag in your application. SDWebImage do simply same written by @karthik but too use cache so you don't need to fetch image every time while displaying.

try this

[userpic sd_setImageWithURL:[URLWithString:imageURL placeholderImage:[UIImage imageNamed:@"blackSquare.png"]]
                         completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                            //Image done
                         }];
Devang Tandel
  • 2,988
  • 1
  • 21
  • 43