我剛剛開始用於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它沒有完成部分,請檢查我的答案 –