title: Accessing JSON Data in Objective C
body: <p>I've downloaded my JSON Data, but I'm having trouble accessing a specific object. From my JSON data, I'm trying to pull the most recent <code>value</code> from <code>variableName = "Elevation of reservoir water surface above datum, ft";</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  
  NSURL *url = [NSURL URLWithString:@"http://waterservices.usgs.gov/nwis/iv/?sites=02334400&amp;period=P7D&amp;format=json"]; 
  
  NSData *jsonData = [NSData dataWithContentsOfURL:url];
  if (jsonData != nil) {
      NSError *error = nil;
  
      id result = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error: &amp;error];
  
      if (error == nil)
          NSLog(@"%@", result);
  }
  }
  </code></pre>
  
  <p>Edited: It's too much data to print the output, but here is how I access the object in JS. I can't seem to write a working for statement that will do the same in Obj-C:</p>
  
  <pre><code> var d = JSON.parse(responseText);
      for (var i = 0; i &lt; d.value.timeSeries.length; i++) {
          if (d.value.timeSeries[i].variable.variableName == 'Elevation of reservoir      water surface above datum, ft') {
              var result = d.value.timeSeries[i].values[0].value[d.value.timeSeries[i].values[0].value.length - 1];
              console.log(result);
          }
  </code></pre>