Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

call method "dictionaryWithObjectsAndKeys:"



I've tried to piece together from the archives how to save a Document in plist xml format, calling the cocoa methods. The document has about 120 fields, not just the 3 in the sample code I include below.
I've show in "--" where the thing is breaking, and other questions.
Any help with syntax?
Thanks,
Joe


on write to file theObject path name pathName of type ofType

log pathName
--/private/tmp/501/TemporaryItems/com.apple.NSDocument_469_92348689_1/ plistSaveTest.dmx
--Why isn't this a 'real' file path? I saved in location Home directory.

set theData to {}

tell window of theObject

set end of theData to ((contents of text field "Key1") as string)
-- if I don't coerce the contents to list the it adds it as a list within a list: {{"data1"},...}
set end of theData to "Key1"
set end of theData to ((contents of text field "Key2") as string)
set end of theData to "Key2"

set end of theData to ((contents of combo box "Key3") as string)
set end of theData to "Key3"
log theData
--{"Data1", "Key1", "Data2", "Key2", "Data3", "Key3"}


end tell

-- It's breaking here, during the "dictionaryWithObjectsAndKeys:" call.
-- Doesn't the AS object list transfer to a Cocoa object Array?
-- I'm sure I don't have the syntax correct.
set theObject to call method "dictionaryWithObjectsAndKeys:" of class "NSDictionary" with parameter theData
log "Just called method dictionaryWithObjectsandKeys:"
set theList to {pathName, true}

log "Just set theList to {pathName, true}"

set testBoolean to call method "writeToFile:" of object theObject with parameters theList

return true
end write to file
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: Apple Scripting an existing Cocoa Application (From: Bill Cheeseman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.