How to create a Save As dialogue with NSSavePanel

Likewise we can save our previously selected file using an NSSavePanel. It too is easy to use, just as the NSOpenPanel.

For a save action to make sense we need to have some data to save, so in this example we will copy an existing file (self.myURL) to the new URL that the save panel returns. We’ll let the NSFileManager just create a copy with a new name that the user specifies using the save panel:

The only alien looking thing here is the use of a Block (like it is in the NSOpenPanel). This is the equivalent to an anonymous function in JavaScript, basically a block of code that runs upon completion. As it’s part of the method call, the closing ] is way at the bottom.

Further Reading

Apple’s NSSavePanel Class Reference:

A Short Practical Guide to Blocks:

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at and

Add your voice!