NSFetchedResultsController with sections created by first letter of a string

后端 未结 7 1518
再見小時候
再見小時候 2020-11-28 01:09

Learning Core Data on the iPhone. There seem to be few examples on Core Data populating a table view with sections. The CoreDataBooks example uses sections, but they\'re ge

7条回答
  •  忘掉有多难
    2020-11-28 01:38

    I like Greg Combs answer above. I've made a slight modification so that strings like "Smith" and "smith" can appear in the same section by converting the strings to upper case:

    - (NSString *)stringGroupByFirstInitial {
        NSString *temp = [self uppercaseString];
        if (!temp.length || temp.length == 1)
            return self;
        return [temp substringToIndex:1];
    }
    

提交回复
热议问题