XCode Warrior
XCode Warrior

Reputation: 21

iOS: Swift: SDWebImage: cell.customImageView.sd_setImage(with: imageURL) crashes

I'm using CocoaPods with SDWebImage (3.8.2) with a new Swift 3 project (XCode Version 8.2.1 (8C1002)) and the following code compiles fine within a UICollectionViewController:

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
      ...
      cell.customImageView.sd_setImage(with: imageURL, completed:{
        (SDWebImageCompletionBlock) in

      })
      ...
    }

I've imported SDWebImage at the top of the swift file. customImageView is a UIImageView defined within a custom UICollectionViewCell

@IBOutlet weak var customImageView: UIImageView!

however this crashes on run with the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView sd_setImageWithURL:completed:]: unrecognized selector sent to instance ...'

Any ideas why this is compiling fine but crashing at runtime?

Upvotes: 0

Views: 492

Answers (2)

Andrian Rahardja
Andrian Rahardja

Reputation: 344

Check the outlet, disconnect and reconnect the outlet of your imageView

Upvotes: 0

DaVinci
DaVinci

Reputation: 125

Add $(inherited) to your 'Other Linker Flags' in the build settings

Upvotes: 1

Related Questions