struct SomeStruct {
var optVar : String?
var nonOptVar : String = "Hello"
var optvar2 : String!
}
let obj2 = SomeStruct(optVar: "a", nonOptVar: "b", optvar2: "c")
let a = obj2.optVar // why it is not asking for force unwraping
let b = obj2.nonOptVar
let c = obj2.optvar2
print(a)
print(b)
print(c)
请分享您对此的看法。但是,虽然我通常在项目中使用可选项,但它通常会给出警告 'Expression 从字符串隐式强制?去任何'