“CGPoint"类型的值在swift 3中没有成员“makeWithDictionaryRepresentation" [英] Value of type 'CGPoint' has no member 'makeWithDictionaryRepresentation' in swift 3

查看:29
本文介绍了“CGPoint"类型的值在swift 3中没有成员“makeWithDictionaryRepresentation"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working with Swift 3. In my code I am using Siri integration in Wallet App.I am getting an error in that App. I searched in google for it but I didn't find the solution for it.

这是我的代码:

 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
    }

这是我得到的错误:

'CGPoint' 类型的值没有成员 'makeWithDictionaryRepresentation'

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

任何人都可以请帮我解决它.提前致谢.

Can any anyone Please help me resolve it. Thanks in Advance.

推荐答案

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

In Swift 3 you need to use init CGPoint(dictionaryRepresentation:).

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

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

It will return optional CGPoint instance so batter to use with if let or guard

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

查看 CGPoint 上的 Apple 文档了解更多信息详情.

Check Apple Documentation on CGPoint for more details.

这篇关于“CGPoint"类型的值在swift 3中没有成员“makeWithDictionaryRepresentation"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆