Questions tagged [nssavepanel]

An NSSavePanel object creates and manages a Save panel and allows you to run the panel in a modal loop

An NSSavePanel object creates and manages a Save panel and allows you to run the panel in a modal loop. The Save panel provides a simple way for a user to specify a file to use when saving a document or other data. It can restrict the user to files of a certain type, as specified by an extension.

An NSSavePanel object manages a panel that allows users to specify the directory and name under which a file is saved. It supports browsing of the file system, and it accommodates custom accessory views.

An NSSavePanel object may have a delegate. The methods that delegates of NSSavePanel may implement are specified by the NSOpenSavePanelDelegate protocol.

In a sandboxed app, when a user saves a document, the Save dialog is presented by the powerbox, not AppKit. OS X then adds the saved file to the app’s sandbox (if necessary) to allow the app to write to the file.

More: NSSavePanel Class Reference

118 questions
2
votes
1 answer

NSSavePanel cancel confirmation

I have a NSSavePanel and I want to handle the "Cancel" button action to prevent closing the sheet. A want to show the confirmation alert above the savePanel sheet like it is done if you want to overwrite file when saving. What is the best way to…
Dmitry
  • 7,300
  • 6
  • 32
  • 55
2
votes
0 answers

Xamarin.Mac NSSavePanel() does not show up and returns "-2" when passing the file access security policy in sandbox in Xcode 14.2

This problem did not happen before macOS Ventura(Xcode 14.2), but I think the process of handling the security policy to Sandbox file access has changed significantly since this current version. I have not changed any code, but when I run…
2
votes
2 answers

NSSavePanel handle actions

Simple question: I want to handle the action for cancel button pressed in my NSSavePanel. I'm using the panel with the delegate class: NSSavePanel *save = [NSSavePanel savePanel]; [save setDelegate:self]; [save runModal]; I saw on the documentation…
DeejonZ
  • 2,451
  • 2
  • 17
  • 19
2
votes
1 answer

Determine which button pressed in Save Panel in NSDocument based application

How should I determine which button is pressed (save, Cancel) when the save dialog is dismissed in an NSDocument based application ? The save panel is the default provided by NSDocument when save is selected from menu. I would like to have the…
Vassilis
  • 2,878
  • 1
  • 28
  • 43
2
votes
4 answers

Why is NSOpenPanel/NSSavePanel showing memory leak?

Not sure why, but making a simple [[NSOpenPanel openPanel] runModal]; creates a memory leak - seen in Leaks Instrument. Seems off. It's an auto-released object, shouldn't it be automatically released after ARpool is drained? Is there a way to fix…
AWF4vk
  • 5,810
  • 3
  • 37
  • 70
2
votes
2 answers

Replace a file using the NSSavePanel in a sandboxed application

I create a NSSavePanel using this code: NSSavePanel *savePanel = [NSSavePanel savePanel]; savePanel.delegate = self; savePanel.directoryURL = ...; savePanel.nameFieldStringValue = ...; [savePanel beginSheetModalForWindow:self.window …
Dev
  • 7,027
  • 6
  • 37
  • 65
2
votes
1 answer

NSSavePanel Swift not saving

I'm trying to save a file in macOS using Swift. I have the following settings in my app: In the info.plist I have this key set with a message I need access to the desktop: Privacy - AppleEvents Sending Usage Description Though I never see the app…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
2
votes
2 answers

Using Cocoa NSSavePanel in non-Sandboxed causes Assertion failure

Only in MacOS 10.15, only when trying to save a file twice to the same directory, and only after opening a NSOpenPanel then tap Cancel or Open. My app hangs up with the following stacktrace and the app does not recover, and I had to kill it. ***…
John
  • 31
  • 2
2
votes
0 answers

Saving a File With SavePanel with Custom UTI

I often create my own document type for my desktop applications. But I have never registered my own custom UTI. Anyway, I want to save a simple Dictionary data as a data (NSData) file like the following. @IBAction func testClicked(_ sender:…
El Tomato
  • 6,479
  • 6
  • 46
  • 75
2
votes
0 answers

NSOpenPanel model window kills main application window

I'm new to Mac application programming. I'm using NSOpenPanel to select a file from system. Once i select a file, and press Cancel/Open button, completionHandler block is getting executed. When OpenPanel window is closed, i am facing following…
Punya
  • 21
  • 1
2
votes
0 answers

How to change/suppress the file already exists message in NSSavePanel?

I use an NSSavePanel to ask users to indicate the file to which they want to save some information. If they choose an existing file I'd simply append the new information to the end. The issue is that OS X would give the following…
saiwing
  • 650
  • 7
  • 13
2
votes
1 answer

NSSavePanel savePanel call going into infinite loop

NSSavePanel * savePanel = [NSSavePanel savePanel]; call is going into infinite loop with below message: 2016-02-15 12:00:16.641 myApp[25026:693813] Localizable string "TG_DEFAULT_6078" not found in strings table "Localizable" of bundle CFBundle…
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
2
votes
0 answers

NSSavePanel crash on El Capitan

I am using NSSavePanel and adding an Accessory View onto it using IKSaveOptions. Pre-Yosemite it worked great and then Yosemite caused a crash as per: NSSavePanel crashes on Yosemite I implemented this fix a year ago. Now El Capitan comes along and…
viperfoth
  • 21
  • 2
2
votes
1 answer

Setting default save location for NSSavePanel

I'm trying to configure my NSSavePanel instance to have the default 'where' location be set to the user's Desktop, as opposed to the Documents folder, which is what it is currently. I tried to modify my code based on this accepted SO answer.…
narner
  • 2,908
  • 3
  • 26
  • 63
2
votes
0 answers

NSSavePanel setDocumentURL in app's document folder

I'm trying to set the directory url in an NSSavePanel so that it opens the panel to that directory but it doesn't work when the I set it to a path in my app's document folder. NSSavePanel *panel = [NSSavePanel savePanel]; NSString *fileFolder =…
Berry Blue
  • 15,330
  • 18
  • 62
  • 113