Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,我下载图像并将它们插入到表格视图中。在我的情况下,可能有几个相同的图像具有相同的 URL。为了减少服务器过载,我只想下载每个图像一次。有对此的内置支持吗?或者实现我的目标的最佳方式是什么?
创建一个NSMutableDictionary并在下载图像并将其放置在表格视图中时,将 URL 添加为字典中的键,并将表格视图行添加为值。在下载图像之前,请检查以确保字典中不包含 URL ( if ([[dictionary allKeys] containsObject:url])。如果没有,请下载图像。如果包含,则获取行号并使空行的图像与字典中行的图像。
NSMutableDictionary
if ([[dictionary allKeys] containsObject:url])
http://example.com/image => 1