无法解决错误“[__NSCFBoolean length]: unrecognized selector sent to instance" [英] Unable to solve the error "[__NSCFBoolean length]: unrecognized selector sent to instance"

查看:22
本文介绍了无法解决错误“[__NSCFBoolean length]: unrecognized selector sent to instance"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码

NSDictionary *dict = [self.catArray objectAtIndex:indexPath.row];
NSURL *U1 =[NSURL URLWithString:[dict objectForKey:@"img"]];

[DownloadManager downloadImageWithURL:[NSURL URLWithString:[dict objectForKey:@"img"]] completionBlock:^(BOOL succeeded, UIImage *image) {
    if (succeeded) {

        [cell.iconImgView setImage:image];

    }
}];

出现错误

[__NSCFBoolean length]:无法识别的选择器发送到实例

[__NSCFBoolean length]: unrecognized selector sent to instance

推荐答案

您的问题与此行有关:

NSURL *U1 =[NSURL URLWithString:[dict objectForKey:@"img"]];

问题是由您假设的事实引起的:

The problem is caused by the fact that you assume:

[dict objectForKey:@"img"]

返回一个 NSString 而实际上它返回一个表示布尔值的 NSNumber.

is returning an NSString when in fact it is returning an NSNumber representing a boolean value.

您需要弄清楚为什么字典中的数据不正确,或者您需要使用正确的密钥来获取 URL.

You need to either figure out why the data in the dictionary is incorrect or you need to use the correct key to get the URL.

这篇关于无法解决错误“[__NSCFBoolean length]: unrecognized selector sent to instance"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆