0
votes

The following code was working fine, until I upgraded the SDWebImage to V.3.7.3, now, it gives me an error. I put ($$) at the beginning and the end of the code that marks me the error, it is under the line _HUD2 = [General showHUDInView:self.productImageView_ And actually starts here: completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)...

- (void)parseResponse:(NSString *)xml{
NSData *data = [xml dataUsingEncoding: NSUTF8StringEncoding];

_parserDetails3 = [[NSXMLParser alloc] initWithData:data];

[_parserDetails3 setDelegate:self];
[_parserDetails3 setShouldProcessNamespaces:YES];
[_parserDetails3 setShouldReportNamespacePrefixes:NO];
[_parserDetails3 setShouldResolveExternalEntities:NO];

if (![_parserDetails3 parse] ) {
    NSLog(@"Error de parseo");
}
else if ([_details3 count] <= 0) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"INFORMATION", nil) message:NSLocalizedString(@"NO_DETAIL_MODAL", nil) delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    [alert show];
}
else {
    NSLog(@"%d", [_details3 count]);

    // Logic to fill general labels
    _estiloLabel.text = [NSString stringWithFormat:@"%@ [%@]", [[_details3 objectAtIndex:0] estilo], [[_details3 objectAtIndex:0] nombreEst]];
    _lineaLabel.text = [[_details3 objectAtIndex:0] linea];
    _fechaSolLabel.text = [[_details3 objectAtIndex:0] fechaSol];
    _chinelaLabel.text = [[_details3 objectAtIndex:0] pielChinela];
    _tuboLabel.text = [[_details3 objectAtIndex:0] pielTubo];
    _specIDLabel.text = [[_details3 objectAtIndex:0] specID];

    NSLog(@"%@", [NSString stringWithFormat: IMAGES_PATH , [[_details3 objectAtIndex:0] imagenMuestra]]);

    /*[self.productImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat: IMAGES_PATH , [[_details3 objectAtIndex:0] imagenMuestra]]] placeholderImage:[UIImage imageNamed:@"cargando.gif"]];*/

    HUD2 = [General showHUDInView:self.productImageView withTitle:NSLocalizedString(@"LOADING", nil) withDetail:NSLocalizedString(@"IMAGE", nil)];
    //La solución de este método obsoleto es agregar 'sd_' a setImage (sd_setImageWithURL)
    $$[self.productImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat: IMAGES_PATH , [[_details3 objectAtIndex:0] imagenMuestra]]] placeholderImage:[UIImage imageNamed:nil] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)$$ {
        [General hideHUD:HUD2];
    }];
}

[_detail3TableView reloadData];
[_detail3TableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];

[General hideHUD:HUD];
}

Error:Incompatible block pointer types sending 'void (^)(UIImage *__strong, NSError *__strong, SDImageCacheType)' to parameter of type 'SDWebImageCompletionBlock' (aka 'void (^)(UIImage *__strong, NSError *__strong, SDImageCacheType, NSURL *__strong)')

2

2 Answers

1
votes

The error message tells you that you try to pass the a block of wrong type: you try

void (^)(UIImage *__strong, NSError *__strong, SDImageCacheType)

instead of the correct

void (^)(UIImage *__strong, NSError *__strong, SDImageCacheType, NSURL *__strong)

The difference is that you have to provide a place for the NSURL* to go. They apparently changed the callback signature. You have to change your code to

[self.productImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat: IMAGES_PATH , [[_details3 objectAtIndex:0] imagenMuestra]]] placeholderImage:[UIImage imageNamed:nil] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *url) {
    [General hideHUD:HUD2];
}];

Note the very last parameter.

0
votes

There is an extra parameter (NSURL *) required in the new version (at the end of the block parameter list definition).

Here is the commit, where this happened, in the SDWebImage repo.