'init'不可用:使用'withMemoryRebound(to:capacity:_)'

时间:2016-09-18 09:26:49

标签: swift swift3 init unsafe-pointers

在Swift3之后,我在UnsafePointer收到错误。虽然调试器提出的解决方案并不是很清楚。

我知道UnsafePointer已在上一个问题Issue with UnsafePointer in SQLite project in Swift中提出,但我很难将其答案与此问题联系起来。

错误:

'init' is unavailable: use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type.

代码:

let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) {
            SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
        }

有谁知道如何修复它?

0 个答案:

没有答案