Reputation: 197
Try this:
Make a new XCode4 Applescript project. In the delegate, paste this code:
on doIt_(sender)
set goodHFSLoc to (path to desktop folder)
set test1 to (POSIX path of goodHFSLoc)
log "test1:"&test1
set theJSPath to "/Users/dave/Desktop/MakeTSLabels.js"
set jsHFSFile to (POSIX file theJSPath)
set test2 to (POSIX path of jsHFSFile)
end doIt_
Hook this method up to a button in the UI window.
Click the button, and you should get this error:
Can’t get POSIX path of class "NSObject".
Apparently, "POSIX file" in ApplescriptObjC doesn't make a file object as the language specification requires. Instead it makes an NSObject.
I need to have an applescript file specifier to provide to Adobe Illustrator's do javascript
command, and I need to use NSBundle's functions to get the javascript file, which is packaged in my application bundle.
Am I doing something wrong?
Upvotes: 1
Views: 734
Reputation:
You will see the same behavior in a Finder or System Events tell statement. The solution is the same for ASObjC - you need to use it as a coercion:
set jsHFSFile to (theJSPath as POSIX file)
Upvotes: 1