Window to save Swift File

Asked

Viewed 78 times

2

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

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 "";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.