在swift中使用块丢失数据

时间:2015-09-28 10:28:41

标签: arrays json swift alamofire

当我试图从服务器获取正确返回的数据时在控制台上打印整个json,但当我在json上徘徊时获得半个json。那么请你告诉我它是怎么回事。如果有人可以帮助我,那将是很好的,在此先感谢。

我的要求是

    let clientApi   : NapaClientAPI = NapaClientAPI.sharedInstance
    clientApi.fetchDataFromServer("URL", parameters:dataDic, success: {(response, error) -> Void in
           println(response)
    }) {(error) -> Void in
         println(error?.description)
    }

在此处获得回复

    Alamofire.request(.POST, apiURL, parameters: parameters, encoding: .JSON).responseJSON { (req, res, json, error) in
                println("Json === \(json)")
                println("Error ===\(error)")

                if json != nil{
                    success(response: json, error: nil)
                }
                else{
                    failure(error: error)
                }

            }

输出:

**Json** === Optional({
    response =     {
        Contacts =         (
                        {
                contact =                 (
                                        {
                        date = "2015-09-07 05:00:30";
                        message = "Dear Dr. sund, Everything is going well, I can't give you an expected finish time yet.";
                        name = sund;
                        prefix = "<null>";
                        "user_messsage_id" = 3;
                    }
                );
            },
                        {
                contact =                 (
                                        {
                        date = "2015-09-07 05:38:23";
                        message = "Dear Dr. Krishan Kumar Sharma, We are in the Recovery Room, everything went well.";
                        name = "Krishan Kumar Sharma";
                        prefix = "Dr.";
                        "user_messsage_id" = 4;
                    },
                                        {
                        date = "2015-09-07 07:51:57";
                        message = "Dear Mr. Krishan Kuram Sharma, In the Recovery Room, everything went well, someone will speak with you soon.";
                        name = "Krishan Kumar Sharma";
                        prefix = "Dr.";
                        "user_messsage_id" = 4;
                    }
                );
            },
                        {
                contact =                 (
                                        {
                        date = "2015-09-22 02:37:21";
                        message = "Dear Mr. xyz, Everything is going well, I can't give you an expected finish time yet.";
                        name = xyz;
                        prefix = "Mr.";
                        "user_messsage_id" = 19;
                    }
                );
            }
        );
        message = success;
        "response_code" = 200;
        "response_status" = 1;
    }; })

**Error** ===nil

enter image description here

0 个答案:

没有答案