【发布时间】:2020-01-25 14:42:26
【问题描述】:
我需要将一个变量从 NSUnt 转换为 Int 以将其作为参数传递给 allocate。
我尝试使用 Int() 进行初始化,但编译器拒绝 cannot invoke initializer for type 'int' with an argument of type '(UInt?)'
这是变量:NSUInteger count
这是调用 allocatelet outPut = UnsafeMutablePointer<Float>.allocate(capacity: count)
如果不进行转换,编译器会生成此错误:
cannot convert value of type 'UInt?' to expected argument type 'Int'
【问题讨论】:
标签: swift type-conversion int uint