2015-09-02 68 views
0

下面的代碼工作正常,直到我將SDWebImage升級到V.3.7.3,現在,它給了我一個錯誤。我把($$)在開始和這標誌着我的錯誤代碼的結束,這是該行_HUD2 = [General showHUDInView:self.productImageView_下,而實際上從這裏開始:completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)...不兼容的塊指針類型| Xcode 6.4 | iOS 8.4

- (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)')

回答

1

錯誤消息告訴你,你試試傳遞錯誤類型的塊:您嘗試

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

而不是正確的

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

區別在於你必須爲NSURL*提供一個地方。他們顯然改變了回調簽名。您必須將您的代碼更改爲

[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]; 
}]; 

請注意最後一個參數。