【问题标题】:using Paragraphs in Xcode in AppleScriptObjC在 AppleScriptObjC 中使用 Xcode 中的段落
【发布时间】:2017-07-27 12:05:47
【问题描述】:
do shell script "mdfind kMDItemCFBundleIdentifier = com.test.sample > ~/Documents/sampleBuilds.txt"
set homeFolder to (path to home folder)
set sampleFiles to paragraphs of (read POSIX file (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))
        
if (count of sampleFiles) is 0 then
    display notification "No Sample builds are present on the system"
else
    set sampleFiles to paragraphs of (read POSIX file (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))                
    display dialog "You have " & (count of sampleFiles) & " build(s) of Sample on your system. Would you like to remove them all? This cannot be undone"

    repeat with c in SampleFiles
        do shell script "rm -rf " & (quoted form of c)
        display notification "Sample build located at " & c & " has been removed from your system"
    end repeat
            
    do shell script "rm -rf ~/Documents/SampleBuilds.txt"
end if

当使用正确的发件人将脚本放入 Xcode 时,我收到错误:

[AppDelegate testScript:]:无法将当前应用程序转换为类型文件。 (错误-1700)就行了

将 sampleFiles 设置为(读取 POSIX 文件(homeFolder 的 POSIX 路径和“/Documents/sampleBuilds.txt”))的段落

关于如何让 AppleScript 应用程序中的 Xcode 接受此脚本有什么想法吗?

【问题讨论】:

    标签: xcode applescript applescript-objc paragraphs


    【解决方案1】:

    不需要强制转换为 POSIX file 即可解决问题。

    set sampleFiles to paragraphs of (read (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))
    

    基本上在AppleScriptObjC中POSIX file foo不起作用,你必须写foo as POSIX file

    旁注:

    阅读文本两次是多余的。您可以删除第二行set sampleFiles to ...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多