微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Ubuntu Linux上,数字类型不会自动桥接到纯Swift中的NSNumber?

在MacOS上,如果你这样做:

import Foundation
let x = Int32(1) as? NSNumber

x是非零的.

在Ubuntu Linux上,如果你这样做(即使使用Swift 3.1.1),x也是零.

我做错了什么,或者这只是在Ubuntu / Linux上使用Swift的基础与NSNumber缺少数字类型的事实?

另见Is it possible to replicate Swifts automatic numeric value bridging to Foundation (NSNumber) for (U)Int8/16/32/64 types?
https://github.com/SwiftyJSON/SwiftyJSON/issues/745

解决方法:

在Linux上没有自动桥接NSNumber.资源:
NSNumber bridging and Numeric types

Considerations for Linux platforms

We do not have bridging on Linux so the as? cast is less important; but if it were to have bridging this would be the desired functionality.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐