我有来自苹果示例代码“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 文档这样说:
对象键:
返回与给定键关联的值。
- (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 值。
最终的问题是上面的行是做什么的?
谢谢