2

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

2つの違いを説明できますか?

どうもありがとう

ポール

4

1 に答える 1

4

NSIndexPathクラスの各インスタンスには、行とセクションの2つのプロパティがあります(ドキュメント
。tableViewの各セルは、一意のindexPath(M番目のセクションのN番目の行)に対応します。多くの場合、セクションは1つだけであり、人々rowはデータを参照するためだけに使用します。

于 2011-08-20T14:56:43.173 に答える