【发布时间】:2010-07-12 19:20:54
【问题描述】:
我有这个来自苹果示例代码“LazyTableImages”的sn-p。在下面的代码中,他们正在初始化 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 值。
最后的问题是上面的行是做什么的?
谢谢
【问题讨论】:
-
不清楚您在问什么,而且格式更加混淆了您的问题。
-
@nicolai 现在还可以还是仍然模棱两可?
标签: iphone objective-c concept