How can i get the response data?

94 Views Asked by At

I don't know how to use the response data. I try to add it to dictionary but when i print it i get :

Swift.LazyForwardCollection, Swift.AnyObject>>

let manager = AFHTTPRequestOperationManager()

    var params : Dictionary = ["username": user, "password": pass, "phone": numb]

    manager.POST(

        "http://happybakuapi.com/tehmin/api_evelazim/signup.php",

        parameters: params,

        success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in

            println("JSON: " + responseObject.description)

            var jsonResult = responseObject as! Dictionary<String, AnyObject>



            println(jsonResult.values)

        },

        failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in

            println("Error: " + error.localizedDescription)

        }

    )
1

There are 1 best solutions below

0
On BEST ANSWER

you can use response of dictionary as below.

let manager = AFHTTPRequestOperationManager()

        var params : Dictionary = ["username":"Aplle", "password": "asdsad", "phone": "919909999099"]

        manager.POST("http://happybakuapi.com/tehmin/api_evelazim/signup.php",parameters: params,

            success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in


                println(responseObject)

                println(responseObject.objectForKey("response"))

                println(responseObject.objectForKey("error_type"))

                println(responseObject.objectForKey("user_exist"))

            },

            failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in

                println("Error: " + error.localizedDescription)

            }

        )

Response Dictionary :

{
    "error_type" = "user isset in database";
    response = false;
    "user_exist" = 1;
}