'[(UIView)]' is not identical to 'UInt8' when using += in Xcode 6 beta 5. Use append method instead?

前端 未结 3 500
独厮守ぢ
独厮守ぢ 2021-01-18 05:35

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

3条回答
  •  春和景丽
    2021-01-18 06:12

    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 with Any, 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.

提交回复
热议问题