2013-05-07 56 views
0

我想写一个AppleScript代码读取文件,当我修改输入对话框写回它使用AppleScriptObjC阅读内容文件,并写入新的内容,它

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

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

请帮我这个。

在此先感谢

回答

0

试试这个:

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