James D. Schwartz James D. Schwartz - 6 months ago 12x
Swift Question

"Cannot assign to property: "any" is immutable" error

contains UIImageViews. I'm trying to give each UIImageView in the array a new center coordinate. Not sure why I'm getting this error for the last line in the for loop... enter image description here

var tiledViewsStack = [AnyObject]()

var randLocInt = Int()
var randLoc = CGPoint()

for var any in tiledViewsStack
randLocInt = Int((arc4random()*10) % 9) // 0, --- 8
randLoc = allCenters[randLocInt].CGPointValue()
any.center = randLoc


Needed to make tiledViewsStack a stack of UIImages, not AnyObjects. Changed var tiledViewsStack = [AnyObject]() to var tiledViewsStack = [UIImageView]().