Brand new to swift and generally limited programming experience. Building a simple proof-of-concept app. Have UI mostly built now trying to pass data between button functions in the UI.
Two buttons are for selecting source and target directories (they use NSOpenPanel to select connected drives), and a third to begin a directory copy via FileManager (unless there's a better way).
What I am unclear on is if I have to set up a variable for each NSOpenPanel items to store their selected URL locations, and then more generally, how to pass the stored paths to the other UI widget so that the directory copy operation begins as intended.
I also believe I need to set up a state type somewhere above where this code sits in the document, but not sure if that state can apply to all three buttons or how that works. Still working my way through various tutorials. Sorry for the nooB question but could not find anything like this on StackOverflow or similar sources. Found random things on NSOpenPanel and FileManager but not both used together.
Here is the beginnings / where I got slowed down.
Button("Source Folder") {
let panel = NSOpenPanel()
panel.canChooseDirectories = true
panel.canChooseFiles = false
panel.allowsMultipleSelection = false
panel.isAccessoryViewDisclosed = false
panel.runModal()
}
Button("Target Drive") {
let panel = NSOpenPanel()
panel.canChooseDirectories = true
panel.canChooseFiles = false
panel.allowsMultipleSelection = false
panel.isAccessoryViewDisclosed = false
if panel.runModal() == .OK {}
}
Button("Begin Transfer") {
func copyItem(atPath: String, toPath: String)
}