| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Sunday, Mar 6, 2005, at 05:41 US/Pacific, Tetsuro KURITA wrote:
I think that "setObject:forKey:" method does not works.
Tetsuro,
Attachment:
nsdict.html
Description: application/applefile
-- AppleScript Studio AppleScript for using NSDictionary
-- Created 2005-03-06 by Philip Aker
-- Put all the NSDictionary stuff in a script so the code doesn't get messed up with the app logic
script mute
property reco : missing value
on add ( theKey , theValue )
if ( reco is equal to missing value ) then
set reco to call method " dictionaryWithObjects:forKeys: " of class " NSDictionary " with parameters {{ theValue }, { theKey }}
else
set dict to call method " dictionaryWithObjects:forKeys: " of class " NSDictionary " with parameters {{ theValue }, { theKey }}
set reco to reco & dict
end if
end add
on add_many ( theKeys , theValues )
if ( reco is equal to missing value ) then
set reco to call method " dictionaryWithObjects:forKeys: " of class " NSDictionary " with parameters { theValues , theKeys }
else
set dict to call method " dictionaryWithObjects:forKeys: " of class " NSDictionary " with parameters { theValues , theKeys }
set reco to reco & dict
end if
end add_many
on value ( theKey )
if ( reco is equal to missing value ) then
return missing value
else
call method " objectForKey: " of reco with parameter theKey
end if
end value
on values ()
return call method " allValues " of reco
end values
on write_file ( thePath )
call method " writeToFile:atomically: " of reco with parameters { thePath , true }
end write_file
end script
-- Now illustrate usage of our NSDictionary script functions
on awake from nib theObject
if ( name of theObject is " main_menu ") then
try
mute 's add (" first ", " value 1 ")
mute 's add (" second ", " value 2 ")
mute 's add (" third ", list folder ( path to preferences from local domain ))
set val to mute 's value (" second ")
log val
set res to mute 's values ()
log res
set dpath to ( POSIX path of ( path to desktop )) & " reco.xml "
mute 's write_file ( dpath )
on error errs number errn
log errs & " : " & errn as string
end try
end if
end awake from nib
Copyright © 2005, Philip Aker
Philip
I used "dictionaryWithObject:forKey:" method instead of "dictionaryWithCapacity:" as follows.
set theDict to call method "dictionaryWithObject:forKey:" of class "NSMutableDictionary" with parameters {"aaa", "hello"}
call method "setObject:forKey:" of theDict with parameters {"hey", "hello"}
set theDescription to call method "description" of theDict
log theDescription -- the result of this log statement is "{hello = aaa; }"
The instance of "NSMutableDictionary" is created. But I can not change contents of the instance.
Philip Aker http://www.aker.ca
_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-studio mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-studio/email@hidden This email sent to email@hidden
| References: | |
| >Re: NSMutableDictionary using call method (From: Tetsuro KURITA <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.