Разница между indexPath и indexPath.row (iphone) - PullRequest
2 голосов
/ 20 августа 2011

Я запутался в indexPath и indexPath.row, каждая ячейка tableView соответствует indexPath?так почему мы ищем «строку» этого indexPath?Я проверил документ, но я думаю, что это смущает меня.

Я нашел этот код:

// this method is used in case the user scrolled into a set of cells that don't have their app icons yet
- (void)loadImagesForOnscreenRows
{
    if ([self.entries count] > 0)
    {
        NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
        for (NSIndexPath *indexPath in visiblePaths)
        {
            AppRecord *appRecord = [self.entries objectAtIndex:indexPath.row];

            if (!appRecord.appIcon) // avoid the app icon download if the app already has an icon
            {
                [self startIconDownload:appRecord forIndexPath:indexPath];
            }
        }
    }
}

Можете ли вы объяснить мне разницу между ними?

Пол

1 Ответ

4 голосов
/ 20 августа 2011

Каждый экземпляр класса NSIndexPath имеет два свойства: строку и раздел ( Документация )
Каждая ячейка tableView соответствует уникальному indexPath (N-я строка в M-м разделе). Часто есть только один раздел, и люди используют только row для ссылки на данные.

...