2017-12-05 4 views
0

Im Arbeiten in einer einfachen App, die Produkte in einer Tabellenansicht zeigt, bekomme ich die Daten von einer JSON API. Das Problem ist, dass die Tabelle aufgrund des synchronen Herunterladens der Bilder verzögert wird. im Versuch, SDWebimage Rahmen zu verwenden, um dies zu lösen, aber ich bekomme diese Fehlermeldung:Asynchroner Bilddownloader Fehler Obj-c SDWebimage

" 'NSInvalidArgumentException', Grund:‚- [UIImageView sd_setImageWithURL: placeholderImage:]: Unbekannter Selektor an Instanz gesendet"

der Code ich habe das ist:

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 
    NSDictionary *dictionary = [self.json objectAtIndex:indexPath.row]; 
    cell.textLabel.text=[dictionary objectForKey:@"name"]; 
    cell.detailTextLabel.text = [dictionary objectForKey:@"description"]; 

    //old synchronous code 
    /* NSString *path = [[[[dictionary objectForKey:@"images"] objectAtIndex:0] valueForKey:@"thumb"] valueForKey:@"url"]; 
    NSString *ruta = [NSString stringWithFormat:@"http://18.221.78.126/ecoferia%@",path]; 
    NSURL *url = [NSURL URLWithString:ruta]; 
    NSData *imgData = [NSData dataWithContentsOfURL:url]; 
    cell.imageView.image = [UIImage imageWithData:imgData]; 
    */ 

    //trying to do asynchronous download of the images 
    NSString *path = [[[[dictionary objectForKey:@"images"] objectAtIndex:0] valueForKey:@"thumb"] valueForKey:@"url"]; 
    NSString *ruta = [NSString stringWithFormat:@"http://18.221.78.126/ecoferia%@",path]; 
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:ruta] 
       placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; 

    return cell; 
} 

ich habe auch die SDWebimage in meinem proyect und importiert in der .m-Datei wie folgt installiert:

#import "SDWebImage/UIImageView+WebCache.h" 

im Super Neu bei objective-c, so dass alle Tipps geschätzt werden.

REGARDS ..

Antwort

0

Die Lösung $ (geerbt) in Build-Einstellungen gesetzt wurde -> Andere Linker-Flags. Funktioniert gut :)