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 8756935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:11:18+00:00 2026-06-13T14:11:18+00:00

I have a UITableView which displays cells with images. On the cellForRowAtIndexPath method I

  • 0

I have a UITableViewwhich displays cells with images. On the cellForRowAtIndexPath method I launch a connection to fetch the image. I want to keep track of what images have been already requested in order to avoid requesting the same image multiple times.

I set up a method like this

+(void) setImageFromURL:(NSURL*) url fromImage:(UIImage*) srcImage to:(UIImageView*) dstImage wasRequested:(BOOL*) requested;

and call it like this

[Utils setImageFromURL:event.thumbURL fromImage:event.thumbImage to:cell.image wasRequested:event.thumbRequested];

where event.thumbRequested is a BOOL property. The method look like this

+(void) setImageFromURL:(NSURL*) url fromImage:(UIImage*) srcImage to:(UIImageView*) dstImage wasRequested:(BOOL*) requested{
    if (srcImage != nil) {
        dstImage.image = srcImage;
    } else if (!requested) {
        requested = YES;
        @try {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                NSData * data = [[NSData alloc] initWithContentsOfURL: url];
                if ( data == nil )
                    return;
                dispatch_async(dispatch_get_main_queue(), ^{
                    __block UIImage* srcImage = [UIImage imageWithData: data];
                    dstImage.image = srcImage;
                });
                [data release];
            });
        }
        @catch (NSException *exception) {
            NSLog(exception.debugDescription);
        }
    }
}

My problem is the BOOL is not changing due to the pass by value behavior in Objective-C. Can anyone recommend a way for being able to update the BOOL in the event object from inside the mehod?

  • 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-06-13T14:11:19+00:00Added an answer on June 13, 2026 at 2:11 pm

    The line:

    requested = YES;
    

    needs to be:

    if (requested) {
        *requested = YES;
    }
    

    The check is just incase nil was passed in for requested.

    Edit: And the call should be:

    BOOL requested = event.thumbRequested;
    [Utils setImageFromURL:event.thumbURL fromImage:event.thumbImage to:cell.image wasRequested:&requested];
    event.thumbRequested = requested;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView which displays images. Every cell has an image and every
I have a UITableView which displays about 5 cells at a time, yet in
I have a grouped UITableView which displays a number of cells, which includes both
I have a UITableView which contains names in each row alongwith images for each
I have a UITableView which I want to populate with details from an array
I'm trying to develop a UITableView which has sectionIndexTitles and which cells have accessory
I have a UITableView , which when I select a row, I want to
I have a UITableView that displays content programmatically. The cells load fine when first
I have a UITableView, which I want to do terribly normal things with, such
I have a UITableView that displays images associated with contacts in each row. In

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.