Вот мой код Json:
{
"status": "error",
"data": "name"
}
вот мой быстрый код:
import UIKit
struct login: Codable {
let status : String
let data : String
}
class ViewController: UIViewController {
@IBOutlet weak var emailLogin: UITextField!
@IBOutlet weak var passwordLogin: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func nextButton(_ sender: Any) {
let username = emailLogin.text
let password = passwordLogin.text
let url = URL(string: "http://parking.onlinekiduniya.org/api/login.php")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
URLSession.shared.dataTask(with: url) {(data, response, error) in
let login = try JSONDecoder().decode(Root.self, from: data!)
}
}
}