Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"]];    
like image 801
Chim Avatar asked Dec 14 '11 13:12

Chim


2 Answers

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
like image 160
Steven Veltema Avatar answered Sep 24 '22 19:09

Steven Veltema


This will solve the problem: Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag: enter image description here

like image 31
Hossam Ghareeb Avatar answered Sep 22 '22 19:09

Hossam Ghareeb