【问题标题】:Using AppleScriptObjC to read content file and write new content to it使用 AppleScriptObjC 读取内容文件并向其写入新内容
【发布时间】:2013-07-20 00:44:31
【问题描述】:

我想编写一个applescript代码,当我修改输入对话框时读取一个文件并写回它

喜欢

set theFile to "/private/etc/hosts"
set theFileContent to read theFile

我使用 Xcode 4.6 创建了一个文本字段和 2 个按钮。我想使用上面的代码来读取主机文件的内容并将其显示在文本字段上,当我修改文本字段并单击保存按钮时,它应该以管理员权限写回主机文件。我试过了,但它们对我不起作用,也许我不知道 applescript 和 applescriptobjc 之间的区别。

请帮帮我。

提前致谢

【问题讨论】:

    标签: xcode applescript applescript-objc


    【解决方案1】:

    试试这个:

    set theFile to ("your/Path/...")
    set theFileHandle to open for access theFile write permission true
    write "someText" to theFileHandle
    close access theFileHandle
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多