Unfortunately I've never written something in ruby therefore I don't understand much of the code you've written. What I tried exactly is:
macbook:~/Desktop dominik$ PLIST=`cat args.plist` macbook:~/Desktop dominik$ echo $PLIST <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-// Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/ PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>debug</key> <integer>1</integer> <key>finalize</key> <integer>1</integer> <key>rootClass</key> <string>my root class</string> </dict> </plist>
Now what I tried macbook:~/Desktop dominik$ tm_dialog -p {$PLIST} MyNib.nib // This returns tm_dialog, usage page macbook:~/Desktop dominik$ tm_dialog -p $PLIST MyNib.nib // The same macbook:~/Desktop dominik$ tm_dialog -p args.plist MyNib.nib // I get the following error:
2007-03-16 01:09:10.776 tm_dialog[4827] *** Uncaught exception: <NSInvalidArgumentException> [NOTE: this exception originated in the server.] *** -[NSCFString setObject:forKey:]: selector not recognized [self = 0x16a5c80] Trace/BPT trap
macbook:~/Desktop dominik$ tm_dialog -p {args.plist} MyNib.nib // The window opens, no error, but the checkboxes aren't checked and my textfield is empty.
Is it wrong to assume, that if I get the values from the nib correctly, it should work the other way around as well!? Maybe I missed a setting in IB?
Dominik
On Mar 16, 2007, at 12:47 AM, Henrik Nyh wrote:
Dominik Gabi wrote:
Thx for your help. I could play a little bit around with tm_dialog the last few days but there are still some things I don't get:
- How do I pass default values to the elements of the nib file. I
tried "tm_dialog -p {arguments.plist} my_nib_file.nib" in several variations but it always results in an error like
Assuming Ruby:
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape" require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist"
to get methods for e.g. shell escaping and plist stuff, respectively. Then you could write code like
defaults = {"key" => "value", "key2" => "value2"} response = `$DIALOG -p #{e_sh defaults.to_plist} #{e_sh "#{ENV ['TM_BUNDLE_SUPPORT']}/nib/SomeDialog.nib"}` response_hash = PropertyList::load(response) puts "key2 is now #{response_hash["key2"]}!"
I believe the hash must have string keys, not symbol keys. e_sh() escapes for the shell.