<分区>
新程序员来了!我正在处理网络请求,下面是我的代码片段。完成网络请求后,我想将请求中的值存储到变量中。但是,当在 if let 语句之外调用变量时,它不会更新。本质上,if let 语句内的 print 语句打印我要查找的值,但 if let
语句外的 print 语句打印我为该变量设置的默认值。变量是全局的。我需要在我的代码中的其他地方使用那个更新的变量,有什么想法吗?
if let data = data {
self.nameLabel.text = data.name
person = data.name
print(person)
}
print(person)