Swift File Save Window

2

I would like to create a window to save text files to disk, but I do not know how to create a File Explorer using Storyboard.

    
asked by anonymous 19.03.2015 / 22:36

1 answer

1

I solved this problem with the following code:

var painelSalvar: NSSavePanel = NSSavePanel();

    painelSalvar.prompt = "Salvar";
    painelSalvar.worksWhenModal = true;
    painelSalvar.title = "Salvar Programa";
    painelSalvar.message = "";
    painelSalvar.runModal();
    var arquivo = painelSalvar.URL;
    if (arquivo != nil){
        let newString : String? = arquivo?.absoluteString!.stringByReplacingOccurrencesOfString("file://", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil);
        return newString!;
    }

    return "";
    
22.03.2015 / 05:57