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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:03:04+00:00 2026-06-06T15:03:04+00:00

I’m having a problem closing my app after NSSavePanel has been used… If I

  • 0

I’m having a problem closing my app after NSSavePanel has been used…
If I open the app, work with it and then close it, it closes in the right way… I have this code in the appdelegate to make my app close

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
 {
   return YES;
 }

but then if I just open the panel to save a txt file… with NSSavePanel… also if I just open it and don’t use it… clicking the “Cancel” button, my app doesn’t close anymore… if I click the red x to close the app the window disappear but the app remain active and there’s no way to bring the main window back up.
The code I’m using to save my txt files is this:

NSSavePanel *save = [NSSavePanel savePanel];

if (nomePartita != nil) 
{
    [save setNameFieldStringValue:nomePartita];
}

[save setAllowedFileTypes:[NSArray arrayWithObject:@"dat"]];
[save setAllowsOtherFileTypes:NO];

NSInteger result = [save runModal];    

if (result == NSOKButton)
{
 // code to save the file here.....
 }

problem must be here in this lines because just with this (I mean with out the rest of my code for creating and saving the txt file) I have this problem…
Anyone has a clue why is this happening?
Any hint will be very much appreciated!
Thanks a lot,
Peace,
Massy

  • 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-06T15:03:05+00:00Added an answer on June 6, 2026 at 3:03 pm

    Try this:

       NSSavePanel*    panel = [NSSavePanel savePanel];
       [panel setNameFieldStringValue:newName];
       [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result){
            if (result == NSFileHandlingPanelOKButton)
            {
                NSURL*  theFile = [panel URL];
                // Write the contents in the new format.
            }
    }];
    

    I faced the same issue and this solved it.
    For window you can alternatively use [NSApp keyWindow]

    Apple guideline with sandboxing.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
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
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.