【发布时间】:2017-08-30 18:19:20
【问题描述】:
我有 JSON 连接,当 JSON 字符串被加载时怎么办,如果没有 - 期望完全加载。在这种情况下,加载后我想显示一条 toast 消息。加载信息时通常会有几秒钟的延迟。
Alamofire.request("https://codewithchris.com/code/afsample.json").responseJSON{ response in
if let value = response.result.value{
let json = JSON(value)
\\ view.makeToast("JSONIsLoaded", duration: 2, position: bottomLayoutGuide, title: "title", image: UIImage (named: "logo.jpg"), style: style ) { (success: Bool) in}
}
}
}
【问题讨论】:
-
搜索
DispatchQueue.main.async -
问题令人困惑。加载后你想做什么?您是否要在加载时显示活动指示器?
-
@Martheli,从 json 中获取一些值并显示出来。只是想大致了解
-
@rmaddy,谢谢