swift NSNumber 转 Sting 遇到的问题
发布时间:2020-12-14 02:09:25 所属栏目:百科 来源:网络整理
导读:编译器报错:Could not cast value of type '__NSCFNumber' (0x...) to 'NSString' (0x...). 解决方案: The value is an NSNumber ,not an NSString . You can use stringValue to convert it: if let a = d [ "a" ] as ? NSNumber { aString a . stringVal
编译器报错:Could not cast value of type '__NSCFNumber' (0x...) to 'NSString' (0x...).
解决方案:
The value is an if let a = d["a"]as? NSNumber { aString a.stringValue println(aString) // -1} If you're sure it's there,you can use forced unwrapping and string interpolation: ]!! "(a)" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |