title: How to reference only the first object in indexPathsForVisibleRows
body: <p>What I'm trying to do is detect which sections of a <code>UITableView</code> are visible, and then change the date of a calendar based on which are visible. </p>
  
  <p>The issue is that there are typically multiple sections viewable at the same time, and I only want to change the date based on the first section index that appears in <code>visibleRowIndexes</code>, not all of them. </p>
  
  <p>Here's my current implementation (Note: I run this function in cellForRowAtIndexPath):</p>
  
  <pre><code>-(BOOL)whatSectionsAreVisible {
  
      NSArray *visibleRowIndexes = [self.agendaTable indexPathsForVisibleRows];
  
      for (NSIndexPath *index in visibleRowIndexes) {
          NSNumber *daySection = @(index.section);
  
          static NSDateFormatter *dateFormatter = nil;
          if(!dateFormatter){
              dateFormatter = [NSDateFormatter new];
              dateFormatter.dateFormat = @"yyyy-MM-dd"; // Read the documentation for dateFormat
          }
  
          // Here is where I will map every index.section to an NSDate
          NSDateComponents *comps = [[NSDateComponents alloc] init];
          [comps setDay:daySection.intValue]; // &lt;&lt;== Extract int from daySection
          [comps setMonth:6];
          [comps setYear:2015];
          NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
          NSDate *date = [gregorian dateFromComponents:comps];
  
          // Update the day selected according to visible section
          [[NSNotificationCenter defaultCenter] postNotificationName:@"kJTCalendarDaySelected" object:date];
  
          // Store currentDateSelected
          [self.calendar setCurrentDateSelected:date];
  
          NSLog(@"The visible section has an index of: %ld", (long)index.section);
  
          if (index.section == 0) {
              NSLog(@"index.row is indeed 0");
              return YES;
          }
      }
      return NO;
  }
  </code></pre>
  
  <p>I tried doing something like <code>NSNumber *daySection = @(index[0].section);</code> instead of <code>NSNumber *daySection = @(index.section);</code>, but that doesn't seem to work. </p>