FoodTracker tutorial Set the accessibility label

In the FoodTracker tutorial, why I got the "Binary opertor '+ ' cannot be applied to operators of type '(Any) -> Int' and 'Int' error? Please kindly help.

Accepted Reply

The compiler seems to consider index to be the name of a function

(Any) -> Int.

My guess is you forgot to change the loop containing the problem line from:

for _ in 0..<starCount { ... }

to:

for index in 0..<starCount { ... }

Replies

// Set the accessibility label
button.accessibilityLabel = "Set \(index + 1) star rating"

The compiler seems to consider index to be the name of a function

(Any) -> Int.

My guess is you forgot to change the loop containing the problem line from:

for _ in 0..<starCount { ... }

to:

for index in 0..<starCount { ... }

Thanks a lot. That solved my problem!