blork/SJODataKit — pull request #2 by lukestringer90 (2014-04-18 22:21:02+00:00)
Title: SJOSearchableFetchedResultsController additions

I was using SJOSearchableFetchedResultsController in a scenario where I wanted to display a section index for a table view. So I made some changes to facilitate this. Mainly the ability to override a method in your subclass to specify the `sectionKeyPath` that should be used when constructed new NSFetchedResultsControllers.

This worked fine but then I released that the table view section index should not be displayed when the user is searching. So the `newFetchedResultsControllerWithSearch:` method takes this into account by ignoring any specified `sectionKeyPath` if the user is searching. This necessitated the `searchIsActive` property, which is set to YES when searching begins, and NO when searching is cancelled.

I also added the ability to construct a SJOSearchableFetchedResultsController with a managed object context if you want to use SJOSearchableFetchedResultsController without being depending on an SJOStore instance.

So to use a section index in a SJOSearchableFetchedResultsController subclass:

```
- (NSString *)sectionKeyPathForSearchableFetchedResultsController:(SJOSearchableFetchedResultsController *)controller {
return @"uppercaseFirstLetterTitle"; // the sectionKeyPath
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return self.sectionIndexes;
}

(NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex:section];
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];
}

- (NSInteger)tableView:(UITableView *)tableView
sectionForSectionIndexTitle:(NSString *)title
atIndex:(NSInteger)index
{
return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];
}
```