Wednesday, September 17, 2014

#1 2012-12-04 07:57:42 pm

Brad Bumgarner
Member
From: Denver, Colorado
Registered: 2002-11-19
Posts: 394
Website

Need help setting up a NSMutableDictionary

I need to set up a NSMutableDictionary with will have 20 key/value pairs. The values will initially be empty lists. I need to use a NSMutableDictionary so I can loop through my code and programmatically reference the keys.

Thanks in advance,
Brad Bumgarner

Offline

 

#2 2012-12-04 09:05:46 pm

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 3623

Re: Need help setting up a NSMutableDictionary

Just create a mutable dictionary, and use setObject_forKey_ to add value/key pairs:

Applescript:

set theDict to current application's NSMutableDictionary's dictionaryWithCapacity_(20)
repeat with i from 1 to 20
   theDict's setObject_forKey_({}, "Key" & i)
end repeat


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2012-12-05 03:53:29 pm

Brad Bumgarner
Member
From: Denver, Colorado
Registered: 2002-11-19
Posts: 394
Website

Re: Need help setting up a NSMutableDictionary

Well, that was MUCH too easy!! lollol I saw the dictionaryWithCapasity_ but couldn't figure out how to get the keys added to it.

Thanks Shane.

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.031 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)