-3

我是 iphone 新手,不明白如何解析这些数据,所以我会在表格视图中显示结果。以下数据是我调用 megento 的 api 时 AFHTTPRequestOperation 的结果。

{
        "callforprice_id" = 13;
        country = Austria;
        "created_time" = "2013-05-03 12:03:05";
        emailid = "indies.tester@gmail.com";
        message = hfhftrfygjh;
        name = "Richard Conover";
        "phone_no" = 8977896;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    },
        {
        "callforprice_id" = 12;
        country = "Antigua and Barbuda";
        "created_time" = "2013-05-03 12:01:24";
        emailid = "indies.tester@gmail.com";
        message = sdfsdfsdfwe;
        name = "Richard Conover";
        "phone_no" = 5645;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    },
        {
        "callforprice_id" = 11;
        country = Angola;
        "created_time" = "2013-05-03 11:58:51";
        emailid = "indies.tester@gmail.com";
        message = 6tyrtyryrty;
        name = "Kaitlyn Matheson";
        "phone_no" = 564564;
        "product_name" = Ottoman;
        "product_options" = "";
        "update_time" = "0000-00-00 00:00:00";
    }
4

3 回答 3

1

如果您想在其中显示数据,请尝试这样,UITableview然后使用这个。,

NSString *str=[[resultArray objectAtIndex:indexPath.row] valueForKey:@"country"];

(或者)

用于获取字典等数据

for(NSDictionary *dict in resultArray){
        NSString *str=[dict valueForKey:@"country"];

    }
于 2013-05-06T06:18:20.113 回答
1

http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_afnetworking/

检查上面的链接按照一步一步的过程。

希望对你有帮助

于 2013-05-06T06:22:28.713 回答
1
  1. 把它完全放在一个 NSArray *jsonDataArray 中。
  2. 在 TableView numberOfRowsInSection 中使用 return [jsonDataArray Count];
  3. 在 tableview SelectRowAtIndexPath 中取一个 NSDictionary *dictionary = (NSDictionary *)[jsonDataArray objectAtIndex:indexPath.row]; 在这本词典中,您将分别获取每个对象
  4. 然后您可以通过 [dictionary objectForKey:@"attribute_name"]; 访问任何元素;
于 2013-05-06T06:23:29.400 回答