我收到此错误并且是 Swift 新手。我想获取数组 >= 5 的最后 5 个点,并将这 5 个点作为数组参数传递给函数。我怎样才能实现这一点并克服这个错误?
无法将类型“ArraySlice”的值转换为预期参数类型“[CGPoint]”
if (self.points?.count >= 5) {
let lastFivePoints = self.points![(self.points!.count-5)..<self.points!.count]
let angle = VectorCalculator.angleWithArrayOfPoints(lastFivePoints)
}
你需要转换ArraySlice
to Array
使用方法Array(Slice<Type>)
if (self.points?.count >= 5) {
let lastFivePoints = Array(self.points![(self.points!.count-5)..<self.points!.count])
let angle = VectorCalculator.angleWithArrayOfPoints(lastFivePoints)
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)