Applescript record to NSDictionary

Hi,

Can someone give me a quick start on how to make a NSDictionary record.

Thanks,
kel

That’s ok. Think I’ve found it:

dictionaryWithObjects:forKeys:

Thanks anyway,
kel

Isn’t there an easier way to make a record? :slight_smile:

Imagine that, stuck on trying to create a record! :smiley:

There are several ways:

In a couple of cases record and dictionary are interchangeable.

To create an NSDictionary from scratch you could write


set asDict to {a:1, b:2}
set nsDict to current application's NSDictionary's dictionaryWithDictionary_(asDict)

or


set nsDict to current application's NSDictionary's dictionaryWithObjectsAndKeys_(1, "a", 2, "b", missing value)

Hi Stefan,

That’s exactly what I wanted to know.

Thanks a lot,
kel

ps. the script is turning out great except for one problem I have to solve. Big problem.

Tomorrow

Hi Stefan,

I finally managed to get back a key value from the NSDictionary. I was having a lot of errors using ObjC until I read your other post about coercing to AppleScript record.

You’re so helpful. I just need to clean up and test the notification script now! :smiley:

Thank you very much,
kel