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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:36:29+00:00 2026-05-19T10:36:29+00:00

I am new to NSOpenPanel/NSSavePanel/NSPanel. I am using NSOpenPanel to choose a directory whose

  • 0

I am new to NSOpenPanel/NSSavePanel/NSPanel. I am using NSOpenPanel to choose a directory whose files my app will iterate over and do some fairly time-consuming processing.

I can call -close on the panel, but that does not return focus to the main window. I have read a lot about “dismissing” the panel – but I haven’t found any methods that “dismiss” rather than “close” a panel or a window.

Is it just that I need to spawn a background thread (NSOperation)?

This is what my -chooseDidEnd:returnCode:contextInfo:

-(void) chooseDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo
    {
    [panel orderOut:self];
    [panel release];

    if (returnCode == NSFileHandlingPanelOKButton)
        {
        [progressIndicator startAnimation:self];
        [self doLotsOfTimeConsumingWork:[[panel URL] path]];
        [progressIndicator stopAnimation:self];
        }
    }

While the NSOpenPanel does go away, my NSProgressIndicator does not animate and the main window doesn’t come alive until after -doLotsOfTimeConsumingWork: completes.

Update
Just looked at NSOperationSample code, and it is looking like that’s the way to go.

  • 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-19T10:36:30+00:00Added an answer on May 19, 2026 at 10:36 am

    Two notes:

    First, in Cocoa, the event handling and drawing happens on the main thread. Hence it is never a good idea to synchronously call lengthy methods there (which is the reason for your unresponsive UI).
    So yes, you should hand off computationally expensive tasks to a secondary thread from this method, like from any IBAction.

    Second, calling [panel release] in that method violates Cocoa’s rules of object ownership! So if you would be leaking the panel without that call, you should fix that in the method where you’re creating the panel.

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

Sidebar

Related Questions

Hello.Am new to ios development.What have to do for NSOpenPanel to work in the
New to javascript/jquery and having a hard time with using this or $(this) to
New to jquery question... Using jQuery, depending on the radio button clicked I would
New to files in C, trying to read a file via fread Here's the
New to XML parsing.I need to read a group of arbitrary XML files. They
New to SharePoint. I'm trying to upload a document to SharePoint using it's CopyIntoItems
New to flash. When playing with a dummy 'tutorial' app, we saw that when
I am new to cocoa programming, Using the below code I want to show
new Android developer here. I'm doing a form that let's users set up some
I get a EXC_BAD_ACCESS while running a NSOpenPanel to select a directory on the

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.