ios - What is the difference between 2 strings initilization in swift given below -
string 1:
var string1=string()
string 2:
var edittag: string!
the top 1 declares , creates instance of string
.
the bottom declares implicitly-unwrapped optional variable can hold string
doesn't create instance of string
.
because bottom optional has value of nil
until contains instance of class. implicitly unwrapping !
make promise filled instance, in init function or similar. because of there's no need check if it's filled or unwrap before using it.
Comments
Post a Comment