我是新来的。我已将网站中的 10 个值解析为 tableview 并链接到详细视图控制器。当点击每个单元格时,如何获得要显示的单个值?
- (void)viewDidLoad
{
[[self tableView]setDelegate:self];
[[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];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
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];
}