title: ios - extract title from youtube API v3 response
body: <p>How do I extract the <code>title</code> from the response of a youtube API call.</p>
  
  <p>Here's the code to get the details of a youtube video.</p>
  
  <pre><code>- (void)getVideoTitle{
      // Set up your URL
      NSString *youtubeApi = @"https://www.googleapis.com/youtube/v3/videos?part=contentDetails%2C+snippet%2C+statistics&amp;id=zB4I68XVPzQ&amp;key=API_KEY";
      NSURL *url = [[NSURL alloc] initWithString:youtubeApi];
  
      // Create your request
      NSURLRequest *request = [NSURLRequest requestWithURL:url];
  
      // Send the request asynchronously
      [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError) {
  
          // Callback, parse the data and check for errors
          if (data &amp;&amp; !connectionError) {
              NSError *jsonError;
              NSDictionary *jsonResult = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&amp;jsonError];
  
              if (!jsonError) {
                  NSLog(@"Response from YouTube: %@", jsonResult);
              }
          }
      }] resume];
  
  
  }
  @end
  </code></pre>
  
  <p>Here's the response.</p>
  
  <pre><code>Response from YouTube: {
      etag = "\"m2yskBQFythfE4irbTIeOgYYfBU/3w7VzHWX6Z741beZqAzUx-AoGQQ\"";
      items =     (
                  {
              contentDetails =             {
                  caption = false;
                  definition = hd;
                  dimension = 2d;
                  duration = PT2M13S;
                  licensedContent = 1;
                  projection = rectangular;
              };
              etag = "\"m2yskBQFythfE4irbTIeOgYYfBU/riulsg6pv-HCB96fEN7edGYXYGg\"";
              id = zB4I68XVPzQ;
              kind = "youtube#video";
              snippet =             {
                  categoryId = 24;
                  channelId = "UCZGYJFUizSax-yElQaFDp5Q";
                  channelTitle = "Star Wars";
                  defaultAudioLanguage = en;
                  description = "Star Wars: The Last Jedi. Arriving in your galaxy December 15.\n\nVisit Star Wars at http://www.starwars.com\nSubscribe to Star Wars on YouTube at http://www.youtube.com/starwars\nLike Star Wars on Facebook at http://www.facebook.com/starwars\nFollow Star Wars on Twitter at http://www.twitter.com/starwars\nFollow Star Wars on Instagram at http://www.instagram.com/starwars\nFollow Star Wars on Tumblr at http://starwars.tumblr.com/";
                  liveBroadcastContent = none;
                  localized =                 {
                      description = "Star Wars: The Last Jedi. Arriving in your galaxy December 15.\n\nVisit Star Wars at http://www.starwars.com\nSubscribe to Star Wars on YouTube at http://www.youtube.com/starwars\nLike Star Wars on Facebook at http://www.facebook.com/starwars\nFollow Star Wars on Twitter at http://www.twitter.com/starwars\nFollow Star Wars on Instagram at http://www.instagram.com/starwars\nFollow Star Wars on Tumblr at http://starwars.tumblr.com/";
                      title = "Star Wars: The Last Jedi Official Teaser";
                  };
                  publishedAt = "2017-04-14T15:56:13.000Z";
                  tags =                 (
                      "star wars",
                      "the last jedi",
                      "daisy ridley",
                      "mark hamill",
                      "adam driver",
                      rey,
                      "kylo ren",
                      "luke skywalker",
                      lucasfilm,
                      trailer
                  );
                  thumbnails =                 {
                      default =                     {
                          height = 90;
                          url = "https://i.ytimg.com/vi/zB4I68XVPzQ/default.jpg";
                          width = 120;
                      };
                      high =                     {
                          height = 360;
                          url = "https://i.ytimg.com/vi/zB4I68XVPzQ/hqdefault.jpg";
                          width = 480;
                      };
                      maxres =                     {
                          height = 720;
                          url = "https://i.ytimg.com/vi/zB4I68XVPzQ/maxresdefault.jpg";
                          width = 1280;
                      };
                      medium =                     {
                          height = 180;
                          url = "https://i.ytimg.com/vi/zB4I68XVPzQ/mqdefault.jpg";
                          width = 320;
                      };
                      standard =                     {
                          height = 480;
                          url = "https://i.ytimg.com/vi/zB4I68XVPzQ/sddefault.jpg";
                          width = 640;
                      };
                  };
                  title = "Star Wars: The Last Jedi Official Teaser";
              };
              statistics =             {
                  commentCount = 54170;
                  dislikeCount = 10550;
                  favoriteCount = 0;
                  likeCount = 341919;
                  viewCount = 14611544;
              };
          }
      );
      kind = "youtube#videoListResponse";
      pageInfo =     {
          resultsPerPage = 1;
          totalResults = 1;
      };
  }
  </code></pre>