Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 922663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:04:12+00:00 2026-05-15T19:04:12+00:00

I have this snippet from apple sample code LazyTableImages . In the code below

  • 0

I have this snippet from apple sample code “LazyTableImages” . In the code below they are initializing the IconDownloader class . So what kind of behavior is this .

*************************This Line ******************************************
    IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath]; 

**************************************************************************

and then

    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];   
    }

and the objectForKey docs says this :

objectForKey:

Returns the value associated with a given key.

- (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.

So should I believe they are setting this line

IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];

just for setting the nil value in the object .

ultimately the question is what does the above line do ?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:04:13+00:00Added an answer on May 15, 2026 at 7:04 pm

    This line :

    IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
    

    isn’t making a new iconDonwloader. It’s just asking the imageDownloadsInProgress object (which I assume is a NSDictionary?) to try to get the IconDownloader object that coprresponds to the key ‘indexPath’ – the current row in the table.

    This bit of code :

    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];   
    }
    

    checks to see if it exists. If it doesn’t (the imageDownloadsInProgress returned nil i.e. it can’t find an object for that key) make a new one and add it to the imageDownloadsInProgress NSDictionary.

    All of this code this means that for each indexPath (each row in the table) there is only ever one IconDownloader object – it stopd you trying to download the icon more than once as you scroll the table up and down.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
I have this snippet of code below. I want to pass the value of
I have this snippet of code used to read data from an AVAssetReaderOutput ,
The following code snippet prints the Pascals triangle,I have got this snippet from the
I have this code (snippet) from a .h file: #import <UIKit/UIKit.h> #import ILView.h /**
I have this snippet of HTML: <div class=clearfix id=menu-file-div> <label id=menu-file-label for=id_menu_file>From File</label> <div
I have this snippet of code: var ShopLogicOptions = {}; ShopLogicOptions.params = {orderId: '
I have this snippet of code private Templates retrieveFromCache(String name) { TemplatesWrapper t =
I have this code snippet: $(function() { $('.toolbar [id^=button]').on('click', function () { $(this) .css('background-color',
I have this Perl snippet from a script that I am translating into Python.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.