NSPathControl to POSIX file with spaces

I’m trying to get a value from a NSPathControl in my XIB and change it into a POSIX file, so I can manipulate it in the Finder (make a copy, rename, etc). My code works, but not if there are any spaces in the path. Any spaces are returned as %20, which doesn’t translate into a POSIX file. Any ideas?


on clicked theObject
	set theFile to (string value of control "sourceXML" of window "main")
	set theFile to (theFile as POSIX file)

	tell application "Finder"
	reveal theFile
	end tell
end clicked


Hi,

the path control returns an NSURL object, you can coerce it to a string path by calling a method of NSURL class


on clicked theObject
	set theFile to (string value of control "sourceXML" of window "main")
	set URLObject to call method "URLWithString:" of class "NSURL" with parameter theFile
	set theAlias to POSIX file (call method "path" of URLObject) as alias
	tell application "Finder"
		reveal theAlias
	end tell
end clicked


Thanks, Stefan, That works great!