Swift issue with nil found while unwrapping an Optional value NSDefautlts

前端 未结 3 874
盖世英雄少女心
盖世英雄少女心 2020-12-22 09:23

Issue with fatal error: unexpectedly found nil while unwrapping an Optional value.

let lastupdate = defaults.stringForKey(\"localdate\")
self.lastUpdate.tex         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-22 09:57

    let lastupdate = defaults.stringForKey("localdate")
    self.lastUpdate.text = {
        if let date = lastupdate {
            return "Updated at \(date)"
        }
        return "Not yet updated"
    }()
    

提交回复
热议问题