我从苹果示例代码“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];
只是在对象设置零值。
最终问题是上述行是做什么的?
感谢
目前还不清楚你在问什么,格式化会让你的问题变得更加混乱。 – 2010-07-12 10:48:22
@nicolai现在还是不明确? – harshalb 2010-07-12 10:53:05