如何将youtube上的视频转换为JSON格式,并在UITableView中列出。我需要在一次20饲料被列出,并在显示更多的按钮,然后下20个结果需要显示。
我期待确切的网址,以获得在这两种情况下的饲料。
现在我正在尝试Url,我给出了一个例子。
http://gdata.youtube.com/feeds/api/videos?start-index=11&max-results=20&v=2&alt=jsonc
http://gdata.youtube.com/feeds/api/videos?start-index=2&max-results=20&v=2&alt=jsonc提前感谢
发布于 2012-08-05 16:38:34
下面的代码解析YouTube JSON to table视图。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row < [[_JSON valueForKeyPath:@"data.items.title"] count]) {
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text =
[[_JSON valueForKeyPath:@"data.items.title"] objectAtIndex:indexPath.row];
cell.detailTextLabel.text =
[[_JSON valueForKeyPath:@"data.items.description"] objectAtIndex:indexPath.row];
}
return cell;
}获取JSON的代码如下:
- (IBAction)refresh:(id)sender {
NSURL *url = [NSURL URLWithString:kStrJsonURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id getJSON) {
_JSON = getJSON;
NSLog(@"%@", _JSON);
[self.tableView reloadData];
} failure:nil];
[operation start];
}您应该阅读关于AFNetworking的入门指南:
https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking
您可以从GitHub下载示例项目并运行它:
https://stackoverflow.com/questions/11814930
复制相似问题