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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:47:09+00:00 2026-05-16T20:47:09+00:00

how to make this code asynchronous?? as this code allow to change image on

  • 0

how to make this code asynchronous??

as this code allow to change image on tap in imageview but right now its slow

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSUInteger sections = [indexPath section]; 

    if (sections  == 3)
    { 
        ltxt.text = [NSString stringWithFormat:@" %d of %d", tap,[a1 count]];


        if(tap<[a1 count]-1) {

            tap++;

    NSString *sa=[a1 objectAtIndex:tap];

            image= [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat: sa,[a1 objectAtIndex:tap ]]]]];


          //  NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0)]; 


            myImageView.image = image;
            //[myimg release];
}
  • 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-16T20:47:10+00:00Added an answer on May 16, 2026 at 8:47 pm

    it depends on how many images you’ll need to request at any given time. a good solution i found for industrial strength design/requests was to create a request funnel (which reduced the number of images). these requests supported cancellation (for when the image view goes off-screen), and were all handled via an NSOperationQueue. there was a ton of threading work (read: not for the noob) to get it seamless, but it worked great for large tables which had many images (since the ceiling is quite low for the number of images you can fit into physical memory on the iOS device with the least amount of memory).

    that’s one ‘right’ way, if you have a lot of images to download. if not, then you can look into implementation using performSelectorInBackground:…, and just let the object perform its own locking/handling. either way, you’ll have to do something/display something while the image is being downloaded, so the calling thread (typically the main thread) is not blocked while the image is received.

    Q::follow-up: thanks but where should i declare this method?? inside if (sections == 3) { } – user437503

    A::it will take the `general’ form:

    - (void)setCellImage:(UIImage *)img {
    /* assert here if called from secondary thread */
        myImageView.image = img;
    }
    
    - (void)udpateImageFollowingTap {
        NSAutoreleasePool * pool = [NSAutoreleasePool new];
        NSString * imageUrl = [self.a1 objectAtIndex:self.tap];
        UIImage * tmpImage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
        [self performSelectorOnMainThread:@selector(setCellImage:) withObject:tmpImage];
        [tmpImage release];
        [pool release];
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        NSUInteger sections = [indexPath section];
        if (sections == 3) {
            ltxt.text = [NSString stringWithFormat:@" %d of %d", tap,[a1 count]];
            if(tap<[a1 count]-1) {
                tap++;
                /* insert code to discard previous image and display loading image indication here */
                [self performSelectorInBackground:@selector(udpateImageFollowingTap) withObject:0];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you make this code work? Just have pyglet installed and change fireball.png
How would I make this code smaller? Maybe a toggle, but people were saying
I want to make this 1332251639632 to this 1332251639 I try this code, but
Is there a way to make this code work? LogonControl.java @Audit(AuditType.LOGON) public void login(String
I have some part of asynchronous code in my handlers, I need make this
How can I make this code work? #!/bin/bash ARRAYNAME='FRUITS' FRUITS=( APPLE BANANA ORANGE )
How can I make this code work? class Meta @array = [:a,:b] def self.method_missing(name,
How to make this css code cross browser compatible using jquery. this code only
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I have this code and I need to make this work: if ($handle =

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.