私はジェネリックプログラミングを行っており、Integerに従っています。何とか私はそれを私が使用できる具体的なIntに入れる必要があります。Swiftは整数を整数に変換します
extension CountableRange
{
// Extend each bound away from midpoint by `factor`, a portion of the distance from begin to end
func extended(factor: CGFloat) -> CountableRange<Bound> {
let theCount = Int(count) // or lowerBound.distance(to: upperBound)
let amountToMove = Int(CGFloat(theCount) * factor)
return lowerBound - amountToMove ..< upperBound + amountToMove
}
}
エラーはlet theCount = Int(count)
です。どの状態:
タイプの引数リスト「(Bound.Stride)」で型 'int型の初期化子を呼び出すことはできません
CountableRange
はそのBound.Stride
SignedInteger
ように定義されているため、エラーがより有用である可能性があり
ファースト(source)。だからエラーが私に言ったかもしれない。
私はそれがInteger
であることを知っていますが、実際にInteger
値を使用するにはどうすればよいですか?
非常にいいです、ありがとう! –