2017-01-09 3 views
-3

walkthroughdidscoll関数、スケーリング、回転、アニメーションの実行に役立つアニメーション関数があります。ここにコードがあります。ここに私が得たエラーのイメージがあります。3つの正確なエラーを引き起こす0のiの場合

Error Image

func walkthroughDidScroll(_ position: CGFloat, offset: CGFloat) { 



    for(i in 0 ..< subsWeights.count){ 

     // Perform Transition/Scale/Rotate animations 
     switch animation{ 

     case .Linear: 
      animationLinear(i, offset) 

     case .Zoom: 
      animationZoom(i, offset) 

     case .Curve: 
      animationCurve(i, offset) 

     case .InOut: 
      animationInOut(i, offset) 
     } 

     // Animate alpha 
     if(animateAlpha){ 
      animationAlpha(i, offset) 
     } 
    } 
} 

答えて

0

あなたはこのようにそれを実行する必要があります。

func walkthroughDidScroll(_ position: CGFloat, offset: CGFloat) { 



    for i in 0 ..< subsWeights.count { 

     // Perform Transition/Scale/Rotate animations 
     switch animation{ 

     case .Linear: 
      animationLinear(i, offset) 

     case .Zoom: 
      animationZoom(i, offset) 

     case .Curve: 
      animationCurve(i, offset) 

     case .InOut: 
      animationInOut(i, offset) 
     } 

     // Animate alpha 
     if(animateAlpha){ 
      animationAlpha(i, offset) 
     } 
    } 
} 

これは例のforループのこのタイプの基本的な構造である:私はCを書いている

for index in 1...5 { 
     print("\(index) times 5 is \(index * 5)") 
    } 

// 1 times 5 is 5 
// 2 times 5 is 10 
// 3 times 5 is 15 
// 4 times 5 is 20 
// 5 times 5 is 25 
1

括弧を削除します。

for i in 0 ..< subsWeights.count {

+0

私はこれもやっているので、長いスタイルのループ。私は自分自身で括弧をスキップするように訓練を受け、次に 'for(index、value)in array'構文を使ってループを書いて、括弧をもう一度入れています。数十年のコード習慣は壊れにくいです。 :/一口... –