4

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.

Lock_85_Dr
  • 57
  • 1
  • 6

1 Answers1

5

You need to call

[cell.carImage sd_setImageWithURL:imageURL
                 placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                          options:SDWebImageRefreshCached];
l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • Thanks for your answer @I0gg3r, but I didn't understand you. So I have to copy that code instead of mine? But I think it's the same, right? Regards. – Lock_85_Dr Nov 12 '14 at 13:50
  • :) Note, I have added `sd_` prefix on method call, that should start working. – l0gg3r Nov 12 '14 at 13:53
  • Thanks again @I0gg3r. I'm going to try that, but I think I have tried yesterday and I still had the same error (but when I click of the sd_setImageWithURL it displays the SWebImage file correctly). Do you know why is that error displaying? Thanks. – Lock_85_Dr Nov 12 '14 at 13:56
  • Try to hit "cmd + k" to clean project, and build again. it should work. – l0gg3r Nov 12 '14 at 13:57
  • OK, I'm going to try with that. Thanks ;) – Lock_85_Dr Nov 12 '14 at 13:58