我刚刚开始用于JSON分析的'Alamofire'。现在我正面临一些问题,如下所示:如何使用swift访问Alamofire区块以外的数据3.0
问题声明:无法访问Alamofire区块之外的数据。
编码的东西:
import UIKit
import Alamofire
class ViewController: UIViewController
{
var dataValue = String()
override func viewDidLoad()
{
super.viewDidLoad()
Alamofire.request("url") .responseJSON
{ response in
dataValue = response.result.value
print(dataValue) // It prints value
}
print(dataValue) //It does not print any thing or nil.
}
}
提示:查找'completionHandler:' –
请为我提供一些示例,完成处理程序,因为我是新手。 –
@Ashish它没有完成部分,请检查我的答案 –