问题
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:
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.
来源:https://stackoverflow.com/questions/40925984/value-of-type-cgpoint-has-no-member-makewithdictionaryrepresentation-in-swif