Boogie Bot in Xcode 9.4.1 return this warning:Variable ‘delegateAssigned’ was never mutated; consider changing to ‘let’ constant



When I try to run Lesson 7 of BoogieBot in Xcode 9 I have this warning: Variable ‘delegateAssigned’ was never mutated; consider changing to ‘let’ constant. I think that’s why the exercise does not work well because it does not show the robot and I can not give orders to the robot.



    private func animate(moves:[Move]) {


        var delegateAssigned = false     –>(warning):  Variable ‘delegateAssigned’ was never mutated; consider changing to ‘let’ constant.

        for move in moves {


            for layer in move.targetLayers(bot: self) {


                let animation = CABasicAnimation(keyPath: move.animationKeyPath)

                if !delegateAssigned {

                    animation.delegate = self



                animation.fromValue = layer.value(forKey: animation.keyPath!)

                animation.duration = moveDuration

                animation.toValue = move.toValue

                animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)

                layer.setValue(animation.toValue, forKey: animation.keyPath!)

                layer.add(animation, forKey: animation.keyPath)



            switch move {

            case .leftArmUp: leftFinger.isHidden = false

            case .leftArmDown: leftFinger.isHidden = true

            case .rightArmUp: rightFinger.isHidden = false

            case .rightArmDown: rightFinger.isHidden = true

            default: break





Could it be because of that or is it normal?

Powered by WPeMatico


You may also like...

Comments are closed.