-1
私は私だけAlamofireを使用してIDを表示しようとしているAlamofireを使用してXcode 8 Swift 3.0で特定のJSONを取得するには?
{
"ID":"ID01",
"pass":"1234",
"mail":"[email protected]"
}
これらのJSONデータを持っている、すべてのJSONオブジェクトは、それをプリントアウトすることができます。あなたがキャストしようとする必要があり
import UIKit
import Alamofire
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Alamofire.request("http://localhost/get.php").responseJSON
{ response in
if let JSON = response.result.value {
print("JSON: \(JSON)")
print(JSON["ID"] as! String)
}
}
}
}
あなたは、その機能を使用していない場合はSwiftyJSONを使用して、なぜ? 'JSON [" ID "]の代わりに? JSON ["ID"]。string'を実行します。 :) – Moritz