我已经尝试了几乎所有方法和组合来解析来自服务器的Dictionary的问题。我知道我会遗漏一些东西,但错误信息并不是很有用,因为它们在Objective C中。
以下是服务器的响应。它是一个字典数组:
{
commentCount = 0;
"country_id" = 225;
"country_name" = "Cdscd";
dislikeCount = 0;
disliked = 0;
firstname = cddd;
imageHeight = 0;
imagePath = "";
imageWidth = 0;
lastname = dccd;
likeCount = 0;
liked = 0;
postid = 127;
posttime = "2014-10-28 17:50:00";
statusUpdate = "gygbibcsa";
"upload_type" = text;
userId = 78;
userimage = "https://harsh.com/nrnimages/1410142960.png";
videoHeight = "";
videoPath = "";
videoThumbnail = "";
videoWidth = "";
},
{
commentCount = 0;
"country_id" = 225;
"country_name" = "United States";
dislikeCount = 0;
disliked = 0;
firstname = ssssss;
imageHeight = 0;
imagePath = "";
imageWidth = 0;
lastname = Shssssh;
likeCount = 0;
liked = 0;
postid = 122;
posttime = "2014-10-27 06:31:38";
statusUpdate = Hello;
"upload_type" = text;
userId = 13;
userimage = "https://harsh.com/nrnimages/1409976093.png";
videoHeight = "";
videoPath = "";
videoThumbnail = "";
videoWidth = "";
}
现在我已经在我自己的数组中分配了这个数组,如下所示:
Alamofire.request(.POST, "http://www.harsh.com/temp/Api/v1/homepage", parameters:objHomeDataDictionary, encoding: .JSON).responseJSON
{
(request, response, JSON, error) in
print("Error homepage:",error)
if var objArray = JSON as? NSArray
{
self.homePageDataArray = objArray
}
}
现在在Array的每个索引都有一个字典,我必须得到它并在表视图中显示每个字典的数据,但我不知道如何做到这一点。