JAL*_*JAL 4 unsafe-pointers swift swift3
在 Swift 2.2 中,我能够将nil有效参数作为有效参数传入一个需要UnsafePointer<UInt8>. 在 Swift 3 中,我不能再这样做了:
func myFuncThatTakesAPointer(buffer: UnsafePointer<UInt8>, length: Int) { /** **/ }
myFuncThatTakesAPointer(buffer: nil, length: 0)
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)Playground execution failed: error: Xcode8Playground-iOS.playground:62:33: error: nil is not compatible with expected argument type 'UnsafePointer<UInt8>' myFuncThatTakesAPointer(buffer: nil, length: 0) ^
我现在是否需要将函数中的指针声明指定为可选?
| 归档时间: |
|
| 查看次数: |
1402 次 |
| 最近记录: |