相关疑难解决方法(0)

NSFetchedResultsController与UILocalizedIndexedCollat​​ion

我正在尝试使用具有混合语言数据的FRC并希望有一个节索引.

似乎从文档中你应该能够覆盖FRC

- (NSString *)sectionIndexTitleForSectionName:(NSString *)sectionName
- (NSArray *)sectionIndexTitles
Run Code Online (Sandbox Code Playgroud)

然后使用UILocalizedIndexedCollat​​ion来获得本地化的索引和节.但遗憾的是,这不起作用,并不是打算使用的:(

有没有人能够使用带有UILocalizedIndexedCollat​​ion的FRC,或者我们被迫使用示例UITableView + UILocalizedIndexedCollat​​ion示例中提到的手动排序方法(示例代码包含在我工作的地方).

使用以下属性

@property (nonatomic, assign) UILocalizedIndexedCollation *collation;
@property (nonatomic, assign) NSMutableArray *collatedSections;
Run Code Online (Sandbox Code Playgroud)

和代码:

- (UILocalizedIndexedCollation *)collation
{
    if(collation == nil)
    {
        collation = [UILocalizedIndexedCollation currentCollation];
    }

    return collation;
}

- (NSArray *)collatedSections
{
    if(_collatedSections == nil)
    {
        int sectionTitlesCount = [[self.collation sectionTitles] count];

        NSMutableArray *newSectionsArray = [[NSMutableArray alloc] initWithCapacity:sectionTitlesCount];
        collatedSections = newSectionsArray;
        NSMutableArray *sectionsCArray[sectionTitlesCount];

        // Set up the sections array: elements are mutable arrays that will contain the …
Run Code Online (Sandbox Code Playgroud)

localization core-data nsfetchedresultscontroller ios uilocalizedcollation

14
推荐指数
2
解决办法
6698
查看次数