0

What i need is to wait till setImageWithURL has finished proccesing the image, here is my code on the viewDidLoad method:

UIImageView *test = [[UIImageView alloc] init];
[test setImageWithURL:[NSURL URLWithString:object.imageUrl]];

Is there anyway to set this method to run synchronous? I have tried the completed block, but for some strange reason it never gets called.

Fernando Santiago
  • 2,128
  • 10
  • 44
  • 75
  • The api contains a couple varieties of this call that include completion blocks. I can't think of any upside to running it synchronously. http://hackemist.com/SDWebImage/doc/Categories/UIImageView(WebCache).html – danh May 31 '14 at 00:36
  • the completed block never gets called – Fernando Santiago May 31 '14 at 01:08

1 Answers1

0

From what I remember SDWebImage doesn't have methods to download/set image synchronously (for obvious reasons). But if your use case wants you to use a synchronous method, try this:

UIImageView *test = [[UIImageView alloc] init];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
[test setImage:image];

Hope this helps.

richsage
  • 26,912
  • 8
  • 58
  • 65
Aditya Sinha
  • 103
  • 6