不兼容的块指针类型 | Xcode 6.4 | iOS 8.4
Incompatible block pointer types | Xcode 6.4 | iOS 8.4
下面的代码工作正常,直到我将 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];
}
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)')
错误信息告诉你你尝试传递错误类型的块:你尝试
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];
}];
注意最后一个参数。
新版本需要一个额外的参数(NSURL *
)(在块参数列表定义的末尾)。
Here is the commit, where this happened, in the SDWebImage repo.
下面的代码工作正常,直到我将 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];
}
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)')
错误信息告诉你你尝试传递错误类型的块:你尝试
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];
}];
注意最后一个参数。
新版本需要一个额外的参数(NSURL *
)(在块参数列表定义的末尾)。
Here is the commit, where this happened, in the SDWebImage repo.