Replacements for NSOpenPanel & NSSavePanel

With NSOpenPanel and NSSavePanel gone what is equivalent functionality?

I've found this snippet of code which seems similar to NSOpenPanel:

let documentPicker = UIDocumentPickerViewController(documentTypes: [kUTTypeFolder as String], in: .open)

(I don't know how to get to the kUTTypeFolder constant, I only found it defined in a .h file, so this generates an error - I haven't actually executed this snippet yet)

I actually need NSSavePanel - is there a comparable function to UIDocumentPickerViewController which would do the job?

If anyone has addressed this issue I'd love to see your solution!

With NSOpenPanel and NSSavePanel gone what is equivalent functionality?

What do you mean by “gone”? What sort of app are you building? AppKit? Mac Catalyst?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I thought those objects had been deprecated and when I got a "Use of unresolved identifier 'NSOpenPanel'" error I assumed they were no longer available. I imported Foundation and UIKit - are they in another module?

Thanks!
Here is the whole of the code... (I get: Use of unresolved identifier 'NSOpenPanel'

import Foundation
import UIKit

class ViewController: UIViewController {

    var fileManager = FileManager()

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func readButtonTapped(_ sender: Any) {
        let dialog = NSOpenPanel()
    }
}


NSOpenPanel is an AppKit API, so it’s not available to UIKit apps.

What sort of app are you building?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I'm building a UIKit app that does remote data collection that needs to be able to create a binary file in the cloud for subsequent processing.

I've started working on a static library to package the file I/O logic and was going to use NSSavePanel in a test app to allow me to specify the URL where the file should be created.

I used NSSavePanel in an iOS app for a similar purpose about 4 years ago, so it *used* to be available. Hence "gone".

I'll have to do further research RE how to approach the problem. It's not really a "document centric" app, just needs to be able to generate the binary file as part of its normal workflow.






I actually fished back in some old files and found the prior work - I was developing a file I/O class for use in an iOS app, but I did the development work for the library in a Mac app. Embarrassed, but I'll repeat the trick since it's so much easier to deal with the file system in MacOS. I'm just getting back into an iOS project and am still feeling my way around in new versions of everything since I last coded.

Thanks Quinn for taking time to steer me straight!
Hi @eskimo, I was curious about how to create an experience similar to NSSavePanel but for Mac Catalyst. I would like the user to choose the location they want to export a file before doing the export process.

I tried using UIDocumentPickerViewController but it is expecting a file URL at initialization time before it can open a export controller. So I tried creating a temporary file using File manager, but that caused problems because the document picker did not know the file type of the export. NSSavePanel is what I'm looking for but thats only available in AppKit.

Thanks

I was curious about how to create an experience similar to
NSSavePanel but for Mac Catalyst.

I don’t know the UIKit APIs for this very well )-:

I tried using UIDocumentPickerViewController

That sounds like the right strategy.

but it is expecting a file URL at initialization time before it can
open a export controller. So I tried creating a temporary file using
File manager, but that caused problems because the document picker did
not know the file type of the export.

Hmmm. Yeah, I got nothing. My advice here is that you open a DTS tech support incident and talk to one of our UIKit experts about this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Replacements for NSOpenPanel & NSSavePanel
 
 
Q