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
22
votes
1 answer

Using Cocoa NSSavePanel in Sandbox causes Assertion failure

I'm trying to use the NSSavePanel and added this line to my code. let test = NSSavePanel() Everytime this code is called the this error appears. I'm not quite sure what is happening here because I'm only creating a new object. Any help…
Mike Nathas
  • 1,247
  • 2
  • 11
  • 29
15
votes
1 answer

How can i use NSSavePanel to select a directory?

I need the user select an existing or a new directory where my app can save a few files. Can i do this with NSSavePanel or is there another directory selector class?
Lothar
  • 12,537
  • 6
  • 72
  • 121
9
votes
1 answer

A smart way to retrieve allowed file types from plist

Scenario: I like to define the allowed file types (content types) in the Info.plist file of my Cocoa application. Therefore, I added them like the following example shows. # Extract from Info.plist [...] CFBundleDocumentTypes
JJD
  • 50,076
  • 60
  • 203
  • 339
8
votes
3 answers

Getting path to users Library folder in OS X

I need to open a NSSavePanel with the users Library folder as destination folder. Normally I would do this by entering ~/Library/ in [NSSavePanel beginSheetForDirectory]. This works fine as long as the application is not sandboxed. For sandboxed…
Øystein
  • 1,163
  • 1
  • 12
  • 23
8
votes
1 answer

NSSavePanel and the Sandbox

I have some problems understanding the new Lion's Sandbox. I know that Lion includes a trusted daemon process called Powerbox whose job is to present and control open/save dialog boxes on behalf of sandboxed applications. Like the Code Signing And…
Dev
  • 7,027
  • 6
  • 37
  • 65
8
votes
1 answer

"Save As" in non-document based application Cocoa

I'm working on a project that essentially creates files via a shell script using "sox". The application is not document-based, all its doing is calling a script that creates files, and doesn't internally save any data. However, I need to prompt…
minimalpop
  • 6,997
  • 13
  • 68
  • 80
8
votes
1 answer

NSSavePanel is not saving a file after sandboxing an app

I'm having a problem saving a string file with NSSavePanel after sandboxing the app for the Mac App Store. I set com.apple.security.files.user-selected.read-write to YES and the NSOpenPanel is working as it should. When I try to save a new file,…
Blue
  • 2,300
  • 3
  • 21
  • 32
8
votes
1 answer

With NSSavePanel, how can the user choose a specific file type to save?

I am writing an application in Cocoa which allows the user to export data in 3 different formats: CSV, JSON, and XML. I have added the allowed extensions to an NSSavePanel: NSSavePanel* saveFile = [NSSavePanel savePanel]; NSArray* extensions =…
BWHazel
  • 1,474
  • 2
  • 18
  • 31
6
votes
2 answers

Saving an NSView to a png file?

I am making a simple program that creates game cards for a game I play. I have sent it out to some friends of mine for testing, but they really want it to save images, not just print them. I have tried to make it save as a .png file. I have to…
Justin
  • 2,122
  • 3
  • 27
  • 47
6
votes
1 answer

How to Convert NSURL to CFURLRef

Apple gives sample code for Creating PDF document. But It uses CFURLRef NSPanel savepanel gives NSURL. I can't convert NSURL to CFURLRef path = CFStringCreateWithCString (NULL, filename, kCFStringEncodingUTF8); url =…
6
votes
1 answer

Mac CGDataConsumerCreateWithFilename: failed to open `.myfile.pdf' for writing: Operation not permitted

I am generating a PDF document and offering the user the option to save it to disk. I present them with an NSSavePanel for them to select the filename to save it as. If they choose a file that already exists, it prompts them if they are sure and…
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
6
votes
1 answer

Custom accessory view for NSSavePanel of NSDocument

Consider a Cocoa NSDocument that supports two document types (e.g. BMP and JPEG). While one type has no save options (e.g. BMP), the other does (e.g. compression level for JPEG). How do you implement this? I understand that you should override…
hpique
  • 119,096
  • 131
  • 338
  • 476
6
votes
2 answers

Timeout when showing NSSavePanel

When showing an NSSavePanel while the app is in background I get the following error: RVS:__54-[NSRemoteSavePanel _runOrderingOperationWithContext:]_block_invoke_0319 : Timeout occured while waiting for the window Remote Window Controller requested…
hpique
  • 119,096
  • 131
  • 338
  • 476
5
votes
2 answers

NSOpenPanel/NSSavePanel crashes in Swift 3

In Swift 3/Xcode8.1/10.12.2 I am trying to use a NSOpenPanel to get a text file with the following code, written by DenBeke @IBAction func browseFile(sender: AnyObject) { let dialog = NSOpenPanel(); dialog.title = "Choose a…
heimi
  • 499
  • 7
  • 16
4
votes
1 answer

macOS - How to have NSSavePanel to add a file extension in the file name?

I'm using this code to give the user the choice to specify a name and a location where to save a plain text file on disk. All seems to work but the saved file hasn't any extension. Actually I have not specify an extension in any part of my code, I…
Cue
  • 2,952
  • 3
  • 33
  • 54
1
2 3 4 5 6 7 8