Two weeks to fix iOS, that's bragging. Hehe, but after a few days of learning or think iOS is very familiar with some features of JavaScript, there are some Java features, seemingly swift set everyone into a language, I still prefer to write Android, but compared to iOS, Swift seems a lot simpler, animations, controls, screen fitting these are all comparable to that of HA. Today, when I was learning iOS, I encountered an exclamation point (! ) Question mark (? ) problem. More tangled, don't know what this means. So take a look at the documentation and see what it means.
Look at two pictures first
Code hint string required? Or an exclamation mark,
function return value hit a question mark
There is a picture can be proven, not deceptive oh.
In fact, the question mark and exclamation point is a optional type, as the name implies is an optional Variant.
In Java we declare that variables are generally initialized, otherwise there may be errors with null pointers.
When declaring a variable in swift, the variable has a value and may not have a value, so Swift writes
var optionalName:String?
The defined optionalname is a controllable type that allows it to have values and no values.
varas! GalleryViewController
The exclamation mark is used here to indicate that the controller type is deterministic, and it is clear that the type must be determined when a strong transfer is made.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The understanding and use of Swift Optional Type (question mark, and exclamation point!)