我對此很陌生。 我已經從網站解析10個值到一個tableview並鏈接到一個詳細視圖控制器。 如何在單擊每個單元格時顯示個別值?如何從NSDictionary中檢索值?
(無效)viewDidLoad中 {
[[自的tableView] setDelegate:自]; [[self tableView] setDataSource:self]; array = [[NSMutableArray alloc] init];
[array removeAllObjects];
NSURL * url = [NSURL URLWithString:@「https://itunes.apple.com/us/rss/topalbums/limit=10/json」]; NSURLRequest * request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];
if(connection)webData = [[NSMutableData alloc] init]; }
- (無效)connectionDidFinishLoading:(NSURLConnection的*)連接{ 的NSDictionary * allDataDictionary = [NSJSONSerialization JSONObjectWithData:WEBDATA選項:0錯誤:無]; NSDictionary * feed = [allDataDictionary objectForKey:@「feed」]; NSArray * arrayOfEntry = [feed objectForKey:@「entry」];
for (NSDictionary *diction in arrayOfEntry){
NSDictionary *title = [diction objectForKey:@"title"];
NSString *label = [title objectForKey:@"label"];
[array addObject:label];
}
[[self tableView] reloadData];
}
你是什麼意思「從表中得到每個值」? – Wain
是否要打印關鍵字和值? –
你可以添加從webservice收到的json輸出到你的問題?這樣可以更容易地幫助你... – Jailbroken