大佬教程收集整理的这篇文章主要介绍了在Swift中,Int有一个带String的隐藏初始化器吗?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
var foo = Int("100")
我在文档中看到以下初始化器:
init() init(_: BuilTin.Word) init(_: DoublE) init(_: Float) init(_: int) init(_: Int16) init(_: Int32) init(_: Int64) init(_: Int8) init(_: Uint) init(_: UInt16) init(_: UInt32) init(_: UInt64) init(_: UInt8) init(_:radix:) init(_builTinIntegerLiteral:) init(bigendian:) init(bitPattern:) init(IntegerLiteral:) init(littleEndian:) init(truncaTingBitPattern: Int64) init(truncaTingBitPattern: UInt64)
extension Int { /// Construct from an ASCII representation in the given `radix`. /// /// If `text` does not match the regular expression /// "[+-][0-9a-zA-Z]+",or the value it denotes in the given `radix` /// is not representable,the result is `nil`. public init?(_ text: String,radix: Int = default) }
var foo = Int("100") // Optional(100) var bar = Int("100",radix: 2) // Optional(4) var baz = Int("44",radix: 3) // nil
怎么会找到那个?使用来自的“技巧”
“Jump to definition” for methods without external parameter names,写相当于
码
var foo = Int.init("100") // ^^^^
然后cmd点击Xcode中的init
以上是大佬教程为你收集整理的在Swift中,Int有一个带String的隐藏初始化器吗?全部内容,希望文章能够帮你解决在Swift中,Int有一个带String的隐藏初始化器吗?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。