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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:43:56+00:00 2026-05-25T19:43:56+00:00

I am accessing the photo library on the iphone and it takes a long

  • 0

I am accessing the photo library on the iphone and it takes a long time to import the pictures i select in my application, how do i run the process on a secondary thread , or what solution do i use to not block the user interface?

  • 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-25T19:43:56+00:00Added an answer on May 25, 2026 at 7:43 pm

    I did a full explanation with sample code using performSelectOnBackground or GCD here:

    GCD, Threads, Program Flow and UI Updating

    Here’s the sample code portion of that post (minus his specific problems:

    performSelectorInBackground Sample:

    In this snippet, I have a button which invokes the long running work, a status label, and I added a slider to show I can move the slider while the bg work is done.

    // on click of button
    - (IBAction)doWork:(id)sender
    {
        [[self feedbackLabel] setText:@"Working ..."];
        [[self doWorkButton] setEnabled:NO];
    
        [self performSelectorInBackground:@selector(performLongRunningWork:) withObject:nil];
    }
    
    - (void)performLongRunningWork:(id)obj
    {
        // simulate 5 seconds of work
        // I added a slider to the form - I can slide it back and forth during the 5 sec.
        sleep(5);
        [self performSelectorOnMainThread:@selector(workDone:) withObject:nil waitUntilDone:YES];
    }
    
    - (void)workDone:(id)obj
    {
        [[self feedbackLabel] setText:@"Done ..."];
        [[self doWorkButton] setEnabled:YES];
    }
    

    GCD Sample:

    // on click of button
    - (IBAction)doWork:(id)sender
    {
        [[self feedbackLabel] setText:@"Working ..."];
        [[self doWorkButton] setEnabled:NO];
    
        // async queue for bg work
        // main queue for updating ui on main thread
        dispatch_queue_t queue = dispatch_queue_create("com.sample", 0);
        dispatch_queue_t main = dispatch_get_main_queue();
    
        //  do the long running work in bg async queue
        // within that, call to update UI on main thread.
        dispatch_async(queue, 
                       ^{ 
                           [self performLongRunningWork]; 
                           dispatch_async(main, ^{ [self workDone]; });
                       });    
    }
    
    - (void)performLongRunningWork
    {
        // simulate 5 seconds of work
        // I added a slider to the form - I can slide it back and forth during the 5 sec.
        sleep(5);
    }
    
    - (void)workDone
    {
        [[self feedbackLabel] setText:@"Done ..."];
        [[self doWorkButton] setEnabled:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iOS app I am accessing the user's photo gallery. The first time
I'm looking at using an NSCollectionView for a photo library application, which will allow
I am in the process of developing a printing application for iPhone. Printing happens
I have an ipad app which takes images from Photos application using ALAssetsLibrary and
Following on from this thread: Accessing MySQL database - D3 Can anyone help with
Is accessing/changing dictionary values thread-safe? I have a global dictionary foo and multiple threads
I would like to allow my iPhone App users to view and select from
When accessing an application I've written FireBug shows that each call to a web
I am trying to access iPhone's photo album photo images through ALAssetsLibrary and upload(send)
I have two options select photo and take photo - I have my select

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.