text fields and plist

This is driving me absolutely batty. I’m trying to capture whats in a text field and write that to a file. I can do this easily in applescript but I’m trying to find the equivalent in applescriptobjc

do shell script “/usr/bin/defaults write /private/tmp/org.busn.postimaging primaryUser” & primaryUser

Any ideas? thanks

You could use NSString’s writeToFile_atomically_encoding_error_ like so:

set thePath to POSIX path of ((path to desktop as string) & “myFile.plist”)
set theString to theTextField’s stringValue()
theString’s writeToFile_atomically_encoding_error_(thePath,1,current application’s NSUTF8StringEncoding,missing value)