SDWebImage : setImageWithURL fails when used to set image of a UITableViewCell

Chim picture Chim · Dec 14, 2011 · Viewed 21.3k times · Source

When call setImageWithURL, it fails with following,

[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x149a20 2011-12-14 18:11:38.060 [781:707] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x149a20'

I can confirm I have included SDWebImage project and required headers correctly as I can use the SDWebImageManager successfully.

Following is the code where I called the UIImageView category method setImageWithURL

NSURL* url = [NSURL URLWithString:@"www.abc.com/abc.png"];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"abc.png"]];    

Answer

Steven Veltema picture Steven Veltema · Jan 23, 2012

As per: linking objective-c categories in a static library

Due to a linker bug in XCode, you need to set the 'Other Linker Flags' setting your build target. Setting the flag as follows should eliminate this error.

-force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a