title: How to implement Alphabetical section headers in a UITableView having content getting from DataBase
body: <p>Till now I have implemented <code>UITableView</code> by populate the contents from the database</p>
  
  <p>By retrieving in an <strong>array from sqlite data base</strong> </p>
  
  <p><code>storedContactsArray = [Sqlitefile selectAllContactsFromDB];</code></p>
  
  <p>so no multiple sections , section headers and returns <code>storedContactsArray.count</code> as number of rows.</p>
  
  <p>Now i need to populate the same data in table view but <strong>The data set in Alpabetical sections in alphabetical order.</strong></p>
  
  <p>I tried with</p>
  
  <pre><code>alphabetsArray =[[NSMutableArray alloc]initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",nil];
  
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return [alphabetsArray count];
  }
  
  - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
        return alphabetsArray;
  }
  
  - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
        return [alphabetsArray objectAtIndex:section];
  }
  </code></pre>
  
  <p><strong><img src="https://i.stack.imgur.com/WrYRw.png" alt="in need as follows"></strong></p>
  
  <p>But in case of <code>numberOfRowsInSectio</code>n it fails since there is no contacts in <code>storedContactsArray</code> initially</p>
  
  <p>Error occurs:  <code>-[__NSArrayM objectAtIndex:]: index 25 beyond bounds for empty array</code></p>
  
  <pre><code>-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
    return [[storedContactsArray objectAtIndex:section] count]
  }
  </code></pre>
  
  <p>any advice of use full links pls</p>