I have been working with the showModalSave_ save panel from Shane’s book and am running into a problem. I have copied it directly out of the book (3rd edition) and I get an “unrecognized selector sent…” error. It seems that the problem is the setDirectoryURL_ portion of the code. When I comment this part out it works fine.
But I want the save panel to automatically take you to a certain folder on the desktop to save to. How can I accomplish this? Any help would be greatly appreciated.
is still cannot seem to get this to work. I still get the same error . Here is the code, I am sure that I incorporated your suggestion the wrong way…
on showModalOpen_()
set myFile to {}
set thePanel to current application's NSOpenPanel's openPanel()
set myDirectoryPath to current application's |NSURL|'s fileURLPath_("/Desktop/Product PSD/")
tell thePanel
setMessage_("Open File:")
-- setAllowedFileTypes_({"tif"})
setTitle_("My Open Panel")
setShowsHiddenFiles_(false)
setDirectoryURL_(myDirectoryPath)
setCanChooseFiles_(true)
setCanChooseDirectories_(true)
setAllowsMultipleSelection_(true)
set returnCode to runModal()
end tell
set returnCode to returnCode as integer
if returnCode = (current application's NSFileHandlingPanelOKButton) as integer then
set theURLs to thePanel's URLs() as list
set progressCount to count of theURLs
repeat with i from 1 to count of theURLs
tell item i of theURLs to set thePosixPath to |path|()
log thePosixPath
set hfsPath to (((thePosixPath as text) as POSIX file) as text)
log hfsPath
set end of myFile to hfsPath
log myFile
end repeat
else
log "Cancel pressed"
error -128
end if
end showModalOpen_
set thePanel to current application's NSOpenPanel's openPanel()
set productFolder to POSIX path of (path to desktop) & "Product PSD/"
set myDirectoryPath to current application's |NSURL|'s fileURLWithPath_(productFolder)
tell thePanel
.