アップルのサンプルコード「LazyTableImages」からのこのスニペットがあります。以下のコードでは、IconDownloaderクラスを初期化しています。それで、これはどのような振る舞いですか。
*************************This Line ******************************************
IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
**************************************************************************
その後
if (iconDownloader == nil)
{
iconDownloader = [[IconDownloader alloc] init];
iconDownloader.CustomObject = CustomObject;
iconDownloader.indexPathInTableView = indexPath;
iconDownloader.delegate = self;
[imageDownloadsInProgress setObject:iconDownloader forKey:indexPath];
[iconDownloader startDownload];
[iconDownloader release];
}
そしてobjectForKeyドキュメントはこれを言います:
objectForKey:
指定されたキーに関連付けられた値を返します。
- (id)objectForKey:(id)aKey
Parameters
aKey
The key for which to return the corresponding value.
Return Value
The value associated with aKey, or nil if no value is associated with aKey.
Availability
* Available in iPhone OS 2.0 and later.
だから私は彼らがこの線を設定していると信じるべきです
IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
オブジェクトにnil値を設定するためだけに。
最終的に問題は、上記の行は何をするのかということです。
ありがとう