title: How to create indexPath from NSArray of Dictionaries
body: <p>Okay I am trying to create an indexPath value from a <code>NSArray</code> of <code>NSDictionary</code> values so that when I go through to my tableview I can place an accessory tick on the side.</p>
  
  <p>I have an <code>NSArray</code> of <code>NSDictionaries</code> that look like this</p>
  
  <pre><code>{
          HAS = 1;
          ISL = 1;
          ISV = 0;
          MAN = BANKING;
          MON = 324;
  }
  </code></pre>
  
  <p>So the array would about 80 of these entries each with different values.. </p>
  
  <p>To create the IndexPath I would need to count the number of unique first letters of <strong>MAN</strong> until <strong>MAN == selected String</strong> This would give me the Section number.</p>
  
  <p>Then I would need to count how many entries are in the selected section type for rows.</p>
  
  <p>I have had some help already from here but I failed to identify a flaw in my logic.. for the row I was counting all of the entires instead of from the start of the selected section which ment my row count was totally stuffed. Below is a example of what I am trying to achieve.</p>
  
  <pre><code>a, aa, b, c, d, dd, ddd, dddd, e, f, g, gg
  </code></pre>
  
  <p>the user selects ddd so the indexpath would be </p>
  
  <p>section</p>
  
  <pre><code>a, b, c, (d), e, f, g = 3
  </code></pre>
  
  <p>row </p>
  
  <pre><code>d, dd, (ddd), dddd = 2
  </code></pre>
  
  <p>I can get the section fine like so</p>
  
  <pre><code>NSArray *MANArray = [sortedArray valueForKey:@"MAN"];
  
  NSMutableArray *letters = [NSMutableArray array];
  NSString *currentLetter = nil;
  for (NSString *string in MANArray) {
      if (string.length &gt; 0) {
          NSString *letter = [string substringToIndex:1];
          if (![letter isEqualToString:currentLetter]) {
              [letters addObject:letter];
              currentLetter = letter;
          }
      }
  }
  NSArray *firstLetterArray = [NSArray arrayWithArray:letters];
  int sectionCount = 0;
  for(int i=0; i&lt;[firstLetterArray count]; i++){
      if( [[firstLetterArray objectAtIndex:i] isEqualToString:completedStringLetter]){
          sectionCount = i;
          NSLog(@"%d", sectionCount);
      }
  }
  </code></pre>
  
  <p>But I am just stuck when trying to get the row count from the selected section.</p>
  
  <p>any help would be HUGELY appreciated.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is what I have done to count until the selected value but like I said its incorrect as it needs to start from the section depending on the first letter.</p>
  
  <pre><code>NSNumber * myNumber = [NSNumber numberWithInteger:[modIdString integerValue]];
  
  //                
  NSArray *subarray = [sortedArray valueForKey:@"MOD"];
  for(int i=0; i&lt;[subarray count]; i++){
     if( [[subarray objectAtIndex:i] isEqualToNumber:myNumber]){
        //you have found it, do whatever you need, and break from the loop
        modelResultIndexPath = nil;
        modelResultIndexPath = [NSIndexPath indexPathForRow:sectionCount inSection:i];
     }
  }
  </code></pre>