[英]How do I display data in a UITableView cell from an NSDictionary?
[英]How do I properly populate the UITableView NSArray from a NSDictionary created using JSONKit?
很長的問題,很抱歉,但是最好的總結是我想做的事情:
我的JSON看起來像:
{
4e8cf1d6c7e24c063e000000 = {
"_id" = {
"$id" = 4e8cf1d6c7e24c063e000000;
};
author = faisal;
comments = (
{
author = adias;
comment = amazing;
},
{
author = nike;
comment = "I concur";
}
);
created = {
sec = 1317772800;
usec = 0;
};
text = "This is a random post";
title = "post # 1";
type = (
punjabi
);
};
4e91fd49c7e24cda74000000 = {
"_id" = {
"$id" = 4e91fd49c7e24cda74000000;
};
author = draper;
comments = (
{
author = adias;
comment = "amazing again";
}
);
created = {
sec = 1318118400;
usec = 0;
};
text = "This is a random post again";
title = "post # 2";
type = (
punjabi
);
};
}
我想做的是最終擁有一個UTTableview,每行都有一個標題(JSON上方的文本):
這是我到目前為止的代碼:
NSString *responseString = [request responseString];
NSDictionary *resultsDictionary = [responseString objectFromJSONString];
如何將所有內容放入UITableView的數組中? 再次發誓,我只是有點生銹。
如果不需要鍵,則可以使用allValues
將其轉換為數組,例如:
NSArray *values = [resultsDictionary allValues];
您的JSON是否真的解析為NSDictionary,或者這是包含NSDictionary實例的NSArray? 如果是后者,那不是嗎?
NSString *textForCell = [[resultsArray objectAtIndex:row] valueForKey:@"title"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.