Value of type 'CGPoint' has no member '

2019-09-05 19:05发布

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.

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'

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

1条回答
再贱就再见
2楼-- · 2019-09-05 19:51

In Swift 3 you need to use 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

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

Check Apple Documentation on CGPoint for more details.

查看更多
登录 后发表回答