I'm having trouble understanding the limitations of AnyObject.
You can see from the header that Array is a struct. Nevertheless, this code works:
var whatobject : AnyObject
whatobject = [1,2]
And it's not just literal arrays:
var whatobject : AnyObject
let arr = [1,2,3]
whatobject = arr
However, I can't assign a struct that I make to whatobject
:
struct S {}
var whatobject : AnyObject
whatobject = S() // error
So an array isn't really a struct after all?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…