0

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

喜欢

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

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

请帮我解决一下这个。

提前致谢

4

1 回答 1

0

尝试这个:

set theFile to ("your/Path/...")
set theFileHandle to open for access theFile write permission true
write "someText" to theFileHandle
close access theFileHandle
于 2013-06-23T10:24:04.453 回答