Kamel Labiad Kamel Labiad - 2 months ago 9
AppleScript Question

How to sent path Control to choose folder prompted value?

I am trying to make a small application using ApllescriptObjC, and I could not figure out how to get to show the the folder path on the Path control, "pathPanel" is the outlet connected to path colntrol
thanks

on selectFolder:sender

set PRJpath to (choose folder)

pathPanel's setURL(PRJpath)


end selectFolder:
enter image description here

Answer

The data types don't match.

  • choose folder returns an AppleScript alias specifier.
  • The parameter of setURL is supposed to be a Cocoa NSURL instance.

To make NSURL from alias specifier first get the POSIX path string of the alias.

set PRJpath to POSIX path (choose folder)

Then create the url

pathPanel's setURL:(current application's NSURL's fileURLWithPath:PRJpath)