I understand that in Swift all variables must be set with a value, and that by using optionals we can set a variable to be set to nil
initially.
What I don't understand is, what setting a variable with a !
is doing, because I was under the impression that this "unwraps" a value from an optional. I thought by doing so, you are guaranteeing that there is a value to unwrap in that variable, which is why on IBActions and such you see it used.
So simply put, what is the variable being initialized to when you do something like this:
var aShape : CAShapeLayer!
And why/when would I do this?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…