Search code examples
iosobjective-cxcodexcode6sdwebimage

No visible @interface for 'UIImageView' declares the selector 'setImageWithURL'


Good afternoon,

I'm trying to use SDWebImage in my TableViewController and I get an error two errors (one for each image element) but I can run the App and I can see that the SDWebImage is working fine, but with those 2 errors.

How is that possible? I'm really happy that SDWebImage worked, but I don't know it's showing those errors and then it's working.

Also I want to say that when I use "setImageWithURL" is working with those 2 errors (but that function is not linked) but when I use "sd_setImageWithURL" is not working and I also have those 2 errors (but the sd_setImageWithURL is linked to the SDWebImage files).

So, which one I have to use? Because I want this to make it work but I want to make it work OK without any errors.

I get the following error:

No visible @interface for 'UIImageView' declares the selector 'setImageWithURL:placeholderImage:options:'

Find below some code:

CarTableViewController.m

#import "CarTableViewController.h"
#import "CarTableViewCell.h"
#import "CarTableViewController.h"
#import "CarDetailViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier = @"carTableCell";



    CarTableViewCell *cell = [tableView

                              dequeueReusableCellWithIdentifier:CellIdentifier];



    if (cell == nil) {

        cell = [[CarTableViewCell alloc]

                initWithStyle:UITableViewCellStyleDefault

                reuseIdentifier:CellIdentifier];

    }



    // Configure the cell...

    cell.makeLabel.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"id"];

    cell.likes.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"likes"];

    cell.comments.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"comments"];

    cell.username.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"username"];

    cell.refuser.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"user_ref"];



    cell.modelLabel.text = [[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"user"];



    NSURL * imageURL = [NSURL URLWithString:[[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"imagen"]];

    [cell.carImage setImageWithURL:imageURL

                  placeholderImage:[UIImage imageNamed:@"placeholder.png"]

                           options:SDWebImageRefreshCached];



    NSURL * imageURL2 = [NSURL URLWithString:[[_jsonArray objectAtIndex:indexPath.row] valueForKey:@"image"]];


    [cell.profileImage setImageWithURL:imageURL2

                      placeholderImage:[UIImage imageNamed:@"image"]

                            options:SDWebImageRefreshCached];



    return cell;

}

And that's my CarTableViewCell.h:

#import <UIKit/UIKit.h>



@interface CarTableViewCell : UITableViewCell



@property (nonatomic, strong) IBOutlet UIImageView *carImage;

@property (nonatomic, strong) IBOutlet UILabel *makeLabel;

@property (nonatomic, strong) IBOutlet UILabel *modelLabel;



@property (nonatomic, strong) IBOutlet UILabel *likes;

@property (nonatomic, strong) IBOutlet UILabel *comments;

@property (nonatomic, strong) IBOutlet UILabel *username;

@property (nonatomic, strong) IBOutlet UILabel *refuser;

@property (nonatomic, strong) IBOutlet UIImageView *profileImage;



@end

Thanks in advance.


Solution

  • You need to call

    [cell.carImage sd_setImageWithURL:imageURL
                     placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                              options:SDWebImageRefreshCached];