ios - 在 Swift 3 中编写 UnsafeMutablePointer

标签 ios swift swift3

下面的代码在以前的 Swift 版本中可以工作,现在编译器拒绝了它。 我需要此函数与 ObjectiveC 的 Swift 互操作。

@objc public static func myFunc(jdUT: Double, _ lon: Double, _ lat: Double,
                                           _ dayLen: Double, _ SbhDeg: Double, _ MgrbDeg: Double,
                                           omsk: UnsafeMutablePointer<Double>)
    {
        var z = somefuncion()
        // this line gives this error : Cannot assign to property: 'omsk' is a 'let' constant
        omsk.memory=z;
    }

最佳答案

错误信息具有误导性。 内存属性 Unsafe(Mutable)Pointer 在 Swift 3 中已重命名为 pointee:

let z = someFunction()
omsk.pointee = z

关于ios - 在 Swift 3 中编写 UnsafeMutablePointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39833378/

相关文章:

ios - 在 Xcode 11.6 中找不到 AppTrackingTransparency 模块

ios - 当我尝试构建我的项目时出现以下错误

swift - 在特定点将 Dictionary AS 值添加到 Dictionary B?

ios - collectionView.cellForItem(在 : indexPath) not working properly

ios - 如何从日期数组中获取最接近当前时间的时间? iOS, swift 3

c# - 如何将 View Controller 加载到容器 View 中?

ios - 数据输入自定义 View 的 Swift 示例(自定义应用内键盘)

ios - 无法将自动布局约束添加到UITableViewCell中的元素

ios - CALayerInvalidGeometry 在 iOS9 上崩溃 "sublayer with non-finite position [inf inf]"

ios - CAGradientLayer 不填充宽度