如何从 AppleScript 访问 Cocoa-AppleScript 应用程序中的捆绑文件? [英] How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?

查看:25
本文介绍了如何从 AppleScript 访问 Cocoa-AppleScript 应用程序中的捆绑文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 AppleScript 中我习惯调用:

In AppleScript I'm used to call:

set audio_file to (path to me as string) & "Contents:Resources:Audio:Music.mp3"
display dialog "Path: " & (quoted form of POSIX path of audio_file)

我现在在 Xcode 的 Cocoa-AppleScript 项目中有此代码.它编译得很好,但脚本根本没有运行.该对话框从不显示.

I have now this code inside a Cocoa-AppleScript project in Xcode. It compiles well, but the script is not running at all. The dialog never shows.

没有 (path to me as string) 它可以工作,但没有路径.

Without the (path to me as string) it works, but without the path.

推荐答案

答案是,在 Cocoa-AppleScript 应用程序中,正确的语法不是:

And the answer is that, in a Cocoa-AppleScript Application, the right sintaxis is NOT:

(path to me as text)

但是:

(path to current application as text)

me 作为自引用无效.正确的是当前应用.

me is not valid as self-reference. The correct one is current application.

希望这对其他人有帮助:)

Hope this helps others :)

这篇关于如何从 AppleScript 访问 Cocoa-AppleScript 应用程序中的捆绑文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆