6

I've been using SDWebImage successfully for long. But with iOS8 its crashing when we set image i.e.

[ myImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"url"]] placeholderImage:[UIImage imageNamed:PROFILE_HOLDER_IMAGE]];

Is there way to avoid it

Cheers

Mann
  • 5,477
  • 6
  • 45
  • 57

3 Answers3

12

They have changed setImageWithURL to sd_setImageWithURL for iOS 8.

Try this new syntax,

[myImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",@"url"]] placeholderImage:[UIImage imageNamed:PROFILE_HOLDER_IMAGE]];
Ramdhas
  • 1,765
  • 1
  • 18
  • 26
VNAIK
  • 170
  • 2
  • 9
1

First of all setImageWithURL:placeholderImage: is deprecated, also you must check if your URL string is not null. Try this approach:

    NSString *imageURLString;

    if (imageURLString && ![imageURLString isEqual:[NSNull null]])
    {
        NSURL *imageURL = [NSURL URLWithString:imageURLString];
        [myImageView sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    }

Also make sure that you use the latest version of SDWebImage.

iOS Dev
  • 4,143
  • 5
  • 30
  • 58
1

Some issues arise when using SDWebImage with iOS8 alongside with the crash, even when upgrading to the latest 3.7.1 version. A quick fix I found is to add the libPods-SDWebImage.a to the list of the linked binaries of the project (Select your project target > Build Phases > Link Binary With Libraries > click the '+' and add libPods-SDWebImage.a).

This is a fix for cocoapods users.

Malloc
  • 15,434
  • 34
  • 105
  • 192