我正在使用 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 let
或 guard
一起使用
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/