ios - 类型 'CGPoint' 的值在 swift 3 中没有成员 'makeWithDictionaryRepresentation'

标签 ios swift swift3 cgpoint

我正在使用 Swift 3。在我的代码中,我在钱包应用程序中使用 Siri 集成。我在该应用程序中遇到错误。我在谷歌中搜索了它,但没有找到解决方案。

这是我的代码:

 func createPath(_ points: NSArray) -> UIBezierPath {
        let path = UIBezierPath()
        var point = CGPoint()

        //CGPointMakeWithDictionaryRepresentation((points[0] as! CFDictionary), &point)
        point.makeWithDictionaryRepresentation((points[0] as! CFDictionary)) // In this line I am getting an error
        path.move(to: point)

        var index = 1
        while index < points.count {

            //CGPointMakeWithDictionaryRepresentation((points[index] as! CFDictionary), &point)
            point.makeWithDictionaryRepresentation((points[index] as! CFDictionary))
            path.addLine(to: point)

            index = index + 1
        }
        path.close()

        return path
    }

这是我遇到的错误:

Value of type 'CGPoint' has no member 'makeWithDictionaryRepresentation'

任何人都可以帮助我解决它。 提前致谢。

最佳答案

在 Swift 3 中你需要使用 init CGPoint(dictionaryRepresentation:)

let point = CGPoint(dictionaryRepresentation:points[0] as! CFDictionary)

它将返回可选的 CGPoint 实例,以便与 if letguard 一起使用

if let point = CGPoint(dictionaryRepresentation:points[0] as! CFDictionary) {
     print(point)
}

CGPoint 上查看 Apple 文档了解更多详情。

关于ios - 类型 'CGPoint' 的值在 swift 3 中没有成员 'makeWithDictionaryRepresentation',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40925984/

相关文章:

ios - AWS Amplify 数据库选项

ios - iOS 中的 GCM(Google Cloud Messaging)(通知和数据负载。)

ios - SpriteKit iPhone/iPhoneX/iPad 尺寸问题

ios - 将视频合成为带有过渡的单个电影

ios - 如何制作一个在 hh :mm:ss:ms 中计算的 Swift 3.0 计时器

ios - XC UITesting 因查找 UIElements 而闪烁

ios - Xcode删除文件位置?

iphone - 解析具有相同名称但具有不同属性的元素

swift - 降低didEnterRegion的阈值

ios - 通用类不将委托(delegate)调用转发给具体子类