不兼容的块指针类型| Xcode 6.4 | iOS 8.4

时间:2015-09-02 16:45:59

标签: ios objective-c xcode uiimage

以下代码运行正常,直到我将SDWebImage升级为V.3.7.3,现在,它给了我一个错误。我将($$)放在代码的开头和结尾处,标记我的错误,它位于_HUD2 = [General showHUDInView:self.productImageView_行下并且实际上从这里开始: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];
}
  

错误:不兼容的块指针类型发送&#39; void(^)(UIImage * __ strong,NSError * __ strong,SDImageCacheType)&#39;参数类型&#39; SDWebImageCompletionBlock&#39; (又名&#39; void(^)(UIImage * __ strong,NSError * __ strong,SDImageCacheType,NSURL * __ strong)&#39;)

2 个答案:

答案 0 :(得分:1)

错误消息告诉您尝试传递错误类型的块:您尝试

[
    [(team 1,team 2), (team 3,team 4)], #day 1
    [(team 1,team 3), (team 2,team 4)], #day 2
    [(team 1,team 4), (team 2,team 3)]  #day 3
]

而不是正确的

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

不同之处在于您必须为void (^)(UIImage *__strong, NSError *__strong, SDImageCacheType, NSURL *__strong) 提供一个位置。他们显然改变了回调签名。您必须将代码更改为

NSURL*

请注意最后一个参数。

答案 1 :(得分:0)

新版本中需要一个额外的参数(NSURL *)(在块参数列表定义的末尾)。

发生这种情况的{p> Here is the commit位于SDWebImage repo