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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:32:56+00:00 2026-05-27T12:32:56+00:00

I’m writing an iPad app and have a problem with ui responsiveness / lock

  • 0

I’m writing an iPad app and have a problem with ui responsiveness / lock up.

I have a UITableView with items, when an item is clicked, it goes out on the internet and fetches that item and displays it. The rest of the program (not shown) will use the item downloaded, so only one item can be downloaded at a time.

Fetching the item can take a long time. During that time I want the user to still be able to scroll around the UITableView, but not to be able to select anything until the previous item clicked has been downloaded.

I know this can be done using threads,blocks, and callbacks, but right now I don’t have time to do that (impossible time constraint).

I thought a quick way would be to download it sequentially and use run loops and a flag like this two step process:

  1. When the user clicks on a table cell didSelectRowAtIndexPath is called, in there I set a global flag, then call the download method to download the item. If the user clicks on another item (before the download is completed, it will see the flag checked and exit that function without downloading anything. Basically this:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        static BOOL alreadyInHere=FALSE;
        if (alreadyInHere) return;
        alreadyInHere=TRUE;
        ....
        downloadItem(...);
        ShowAndUseItem(...);
        alreadyInHere=FALSE;
    }
    

    This allows the user to select only one item at a time.

  2. To allow the user to be able to still scroll around the UITableView during the long download, I put in a run loop in the downloadItem(…) method shown above like this…

    -(void) downloadItem(....)
    {
        BOOL downloading=TRUE;
        callFunctionsToStartdownload(...); //
        while (downloading) {
            downloading=DownloadSomeBytes(...);  
            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.5, YES);
        }
    }
    

The result of (1) and (2) is that the user can still scroll around the UITableView during the sequential download, the alreadyInHere flag prevents them from selecting something and starting another download.

This works in most cases, but around 50% of the time, during the download, the UITableView becomes unresponsive (can’t scroll to other items in the table), and even after the download didSelectRowAtIndexPath is never called again when you click on something making theUITableView basically locked up.

My question is, did I do the runLoop correctly?

I know there are other ways to do it, but I have to do it using this general method for now because of other reasons.

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-27T12:32:57+00:00Added an answer on May 27, 2026 at 12:32 pm

    You should not try to download or do any other potentially long activity in youR tableview didSelectRow method. Exit (return) from this UI method after setting up an asynchronous download so that you don’t lock up the UI.

    Locking out simultaneous downloads is still ok, but you want be careful to reset state after errors or timeouts.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.