In a recent question, the poster had this interesting line of code:
self.view.backgroundColor = .whiteColor()
I was surprised to see this. I've only ever seen the leading dot notation used for enum values. In this case, backgroundColor
is of type UIColor?
and whiteColor
is a class method on UIColor
that returns a UIColor
.
Why does this work? It this a legitimate way to call a factory method?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…