swift NSNumber 转 Sting 遇到的问题
2015-06-09 11:09
344 查看
编译器报错:Could not cast value of type '__NSCFNumber' (0x...) to 'NSString' (0x...).
解决方案:
The value is an
not an
You can use
convert it:
If you're sure it's there, you can use forced unwrapping and string interpolation:
解决方案:
The value is an
NSNumber,
not an
NSString.
You can use
stringValueto
convert it:
if let a = d["a"] as? NSNumber { let aString = a.stringValue println(aString) // -1 }
If you're sure it's there, you can use forced unwrapping and string interpolation:
let a = d["a"]! as! NSNumber let aString = "\(a)"
相关文章推荐
- Swift的函数与函数指针、闭包Closure等相关内容介绍
- swift -Storyboard- 自适应布局
- swift的struct结构体类型介绍使用
- IOS9 Swift
- 通过示例分析Swift单例模式
- swift-基础部分
- swift学习笔记
- 【swift】15-0608 方法
- Swift学习笔记七
- iOS swift lazy loading
- Swift的enum枚举类型介绍
- Swift学习笔记六
- Swift中string转换float/double的若干方法
- Swift中常用标准库函数的使用
- 在Swift项目中使用OC,在OC项目中使用Swift
- Swift之单例模式
- swift 时间戳转为date (unix)
- swift学习记录(swift的类型推断)
- swift菜鸟群 欢迎学Swfit 的新手 老手加入 102916734
- 在项目里交叉使用Swift和OC