简体   繁体   English

swift 3中类型“ CGPoint”的值没有成员“ makeWithDictionaryRepresentation”

[英]Value of type 'CGPoint' has no member 'makeWithDictionaryRepresentation' in swift 3

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. 我正在使用Swift3。在我的代码中,我正在Wallet App中使用Siri集成。该App出现错误。 I searched in google for it but I didn't find the solution for it. 我在Google中搜索了它,但没有找到解决方案。

Here is my code: 这是我的代码:

 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
    }

Here is the error I am getting: 这是我得到的错误:

Value of type 'CGPoint' has no member 'makeWithDictionaryRepresentation' 类型“ CGPoint”的值没有成员“ makeWithDictionaryRepresentation”

Can any anyone Please help me resolve it. 谁能帮我解决这个问题。 Thanks in Advance. 提前致谢。

In Swift 3 you need to use init CGPoint(dictionaryRepresentation:) . 在Swift 3中,您需要使用init CGPoint(dictionaryRepresentation:)

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

It will return optional CGPoint instance so batter to use with if let or guard 它会返回可选CGPoint实例,以便与连击使用if let还是guard

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

Check Apple Documentation on CGPoint for more details. 有关更多详细信息,请参阅CGPoint上的Apple文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM