james james - 1 year ago 342
Swift Question

Expected Sequence expression swift 3

I'm using a loop to set the original image for tab bar items so the unselected state isn't gray (my original icons are white). However, it looks like the recent Xcode 8 update broke the code:

for (items in 0 ..< tabBar.items!.count ){
let tabItemIndex = tabBar.items![items]
tabItemIndex.image = tabItemIndex.image!.withRenderingMode(UIImageRenderingMode.alwaysOriginal)


I'm getting the following errors on the first line:
Expected 'in' after for-each pattern
Expected Sequence expression for for-each loop
, and
Expected pattern

Can anyone please help me fix this solution? It worked great until today.


Answer Source

for x in y is an actual expression in Swift. You cannot break it up with parentheses, for (x in y) — that separates the for from the in and causes the expression to seem like nonsense to the compiler.

So, delete the parentheses and all will be well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download