Saludos a Todos
Estoy tratando de acceder a los valores del Result
{"Result":{"CODIGO":"Error","DESCRIPCION":"true","ID":"23"}}
El Controller , por ahora solo accedo al Result.
class FirstViewController: UIViewController {
@IBOutlet weak var txtCarta: UITextField!
@IBOutlet weak var botonEnviar: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func Mostrar(sender: UIButton) {
let envio = txtCarta.text!
let body = "codigo="+envio
let myUrl = NSURL(string: "AquiVaMiUrl");
let request = NSMutableURLRequest(URL:myUrl!);
request.HTTPMethod = "POST";
request.HTTPBody = body.dataUsingEncoding(NSUTF8StringEncoding);
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
if error != nil
{
print("error=\(error)")
return
}
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print(responseString!)
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
// aqui solo accedo a Result pero me falta obtener sus valores.
let blogs = json["Result"]!
print(blogs!)
} catch {
print("error serializing JSON: \(error)")
}
}
task.resume()
}
}
Gracias.