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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:22:30+00:00 2026-06-05T11:22:30+00:00

In my app, I use operations to perform time-intensive tasks, so my user interface

  • 0

In my app, I use operations to perform time-intensive tasks, so my user interface won’t freeze. For that, I use NSInvocationOperation. I wanted to test the overall architecture first before implementing the code to actually complete the tasks, so that’s what I have right now:

// give the object data to process
- (void)processData:(NSObject*)dataToDoTask {

    ... // I store the data in this object

    NSInvocationOperation *newOperation =
    [[NSInvocationOperation alloc] initWithTarget:self
                                         selector:@selector(performTask)
                                           object:nil];

    [[NSOperationQueue mainQueue] addOperation:newOperation];

    ...

}

// process data stored in the object and return result
- (NSObject*)performTask {

    [NSThread sleepForTimeInterval:1]; // to emulate the delay
    return [NSString stringWithFormat:@"unimplemented hash for file %@", self.path];
}

However, the sleep doesn’t work as I expect: instead of delaying the operation completetion, it freezes the app. It seems that I either operations or sleep incorrectly, but I can’t figure out which and how.

  • 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-05T11:22:32+00:00Added an answer on June 5, 2026 at 11:22 am

    That is because you are running your operation on the main thread (the same running your user interface).

    If you want to run your operation concurrently, create a new operation queue:

    NSOperationQueue * queue = [NSOperationQueue new];
    [queue addOperation:newOperation];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django app that use a django-tagging. I need to port this
I have a console command line app that use NHibernate . I am trying
We are about to post an app that use UDID. We plan to remove
My app has a GtkFileChooserButton that you can use to open a chooser widget
I'm currently working on an iPhone app that is fairly data intensive. It downloads
I have a Perl app that runs some perforce operations, in the end I
In my app I use the camera, and when the user takes a picture,
if your app use this solution , do do you plan port the app
In my app I use a static database to store all counties and census
I recently configured my app to use the new AppStats feature of GAE. However,

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.