I was using += to an a UIView to an array and that no longer seems to work. The line
dropsFound += hitView
Gives an error '[(UIView)]' is not identical to 'UInt8'
Here is part of the method. Note that as of Xcode 6 beta 5, hitTest now returns an optional, so it was necessary to say
hitView?.superview
instead of
hitView.superview
in the 'if' statement.
func removeCompletedRows() -> Bool {
println(__FUNCTION__)
var dropsToRemove = [UIView]()
for var y = gameView.bounds.size.height - DROP_SIZE.height / 2; y > 0; y -= DROP_SIZE.height {
var rowIsComplete = true
var dropsFound = [UIView]()
for var x = DROP_SIZE.width / 2; x <= gameView.bounds.size.width - DROP_SIZE.width / 2; x += DROP_SIZE.width {
let hitView = gameView.hitTest(CGPointMake(x, y), withEvent: nil)
if hitView?.superview === gameView {
dropsFound += hitView
} else {
rowIsComplete = false
break
}
}
... remainder of method omitted
That changed in the last release. From the beta 5 release notes:
The
+=
operator on arrays only concatenates arrays, it does not append an element. This resolves ambiguity working withAny
,AnyObject
and related types.
So if the left side of +=
is an array, the right now must be as well.
so:
dropsFound.append(hitView)
Or if you really wanted to use +=
you could probably do:
dropsFound += [hitView]
But that would be a little silly. Use append
like the error message suggests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With