加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 使用不兼容类型’id’的表达式初始化’double’

发布时间:2020-12-16 04:53:01 所属栏目:百科 来源:网络整理
导读:我试图使用以下代码为double赋值: double distanceFormat = [self.runsArray[indexPath.row] valueForKey:@"runDistance"]; 但我不断收到以下错误: Initialising 'double' with an expression of incompatible type 'id' 但是,我知道价值是双倍的!有没有
我试图使用以下代码为double赋值:
double distanceFormat = [self.runsArray[indexPath.row] valueForKey:@"runDistance"];

但我不断收到以下错误:

Initialising 'double' with an expression of incompatible type 'id'

但是,我知道价值是双倍的!有没有办法做到这一点?

解决方法

你可以尝试:
double distanceFormat = [[self.runsArray[indexPath.row] valueForKey:@"runDistance"] doubleValue];

如果你确定它是双倍的,我认为它会起作用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读