NSFetchedResulstsSectionInfo objectAtIndex的语法 - Swift

时间:2014-08-22 13:26:51

标签: ios objective-c swift nsfetchedresultscontroller subscript

我希望在swift中符合以下Objective-c语法。我查看了其他示例,并认为我需要使用"下标语法"

我在其他陈述中取得了成功,但是我在下面的陈述中画了一个空白:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSInteger rows = 0;
    if ([[self.fetchedResultsController sections] count] > 0) {
        id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
        rows = [sectionInfo numberOfObjects];
    }
    return rows;
}

1 个答案:

答案 0 :(得分:0)

感谢Kalpesh在http://rshankar.com/coredata-tutoiral-in-swift-using-nsfetchedresultcontroller/

上找到了答案
return self.fetchedResultsController.sections[section].numberOfObjects