简体   繁体   中英

Syntax for NSFetchedResulstsSectionInfo objectAtIndex - Swift

I'm looking to conform the following objective-c syntax in swift. I have looked at other examples and believe I need to use the "subscript syntax"

I've had success with other statements, however i have drawn a blank on the one below:

- (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;
}

感谢Kalpesh在http://rshankar.com/coredata-tutoiral-in-swift-using-nsfetchedresultcontroller/上找到了答案

return self.fetchedResultsController.sections[section].numberOfObjects

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM