2013-02-11 3 views
0

저는 AFNetworking을 사용하여 UITableView에서 JSON 데이터를 구문 분석합니다. YouTube API는 JSON 데이터에 최대 50 개의 동영상을 제공합니다. 나는 100 개 이상의 비디오를로드해야하고 어떻게해야할지 모르겠다. 여기UITableView에 50 개 이상의 YouTube 동영상을로드하는 방법은 무엇입니까?

http://gdata.youtube.com/feeds/api/playlists/PL7CF5B0AC3B1EB1D5?v=2&alt=jsonc&max-results=50

그리고 내 코드입니다 :

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 


    NSString *urlAsString = @"http://gdata.youtube.com/feeds/api/playlists/PL7CF5B0AC3B1EB1D5?v=2&alt=jsonc&max-results=50"; 


    NSURL *url = [NSURL URLWithString:urlAsString]; 

    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 

    // This will initiate the request and parse the data using apples JSONSerialization 

    AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { 



     self.videoMetaData = [JSON valueForKeyPath:@"data.items.video"]; 

     // This will have all the sq and hq thumbnails 

     self.allThumbnails = [JSON valueForKeyPath:@"data.items.video.thumbnail"]; 

답변

1

start-index - 옵션을 제공 여기

내가 API에서 파일을 얻기 위해 사용하고있는 URL입니다. 예를 들어 : &start-index=51을 추가하여
http://gdata.youtube.com/feeds/api/playlists/PL7CF5B0AC3B1EB1D5?v=2&alt=jsonc&max-results=50
  • 받기 향후 50 개 결과 :

    1. 이 URL 50 결과를 얻을 수
      http://gdata.youtube.com/feeds/api/playlists/PL7CF5B0AC3B1EB1D5?v=2&alt=jsonc&max-results=50&start-index=51

    YouTube API v. 2.0 reference를 참조하십시오.

  • +0

    오케이 그래서 여러 URL을 사용해야합니다. 한 페이지에 모든 결과를 보려면 어떻게합니까? – user1951876

    +0

    예를 들어 결과를 'NSMutableArray'에 넣을 수 있습니다. – Emil

    +0

    AFJSONRequestOperation을 여러 번 사용하고 결과를 새 배열에 추가해야합니까? – user1951876

    관련 문제