2013-05-07 89 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