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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Work for me. Your bug is likely elsewhere... http://jsfiddle.net/6aBfD/ UPDATE… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer In South, I have added a "#@PydevCodeAnalysisIgnore" to the templates… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer Your management may be focused on getting working features into… May 16, 2026 at 12:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an HTML snippet like this : <a href=XXXXXXXXXXXXXXX target=_blank class=view_job_link>View or apply
I'm having problems with the getline instruction from fstream. this is a snippet from
I can't get this working for the life of me. Here is a snippet
I have a link from anther website that I do not have control of
I have the following code in my microcontroller project: if (newThrottle < currentThrottle) {
I'm trying to display a UIImage in real-time coming from the camera, and it
I've been pretty good at fixing my Xcode Obj-C errors, but this one has
I have a MySQL database of newspaper articles. There's a volume table, an issue
I have the following in my XSL which adds a xmlns to my XML.
My question does not really have much to do with sqlalchemy but rather with

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.