My current problem is, I need to find a way to get the file name and
desktop position of all items on the desktop. I have this script
which works (In a way):
tell application "Finder"
set names to name of items of desktop
set positions to desktop position of items of desktop
return {names, positions}
end tell
Two 'get' events - one to get all names, one to get all positions - is
as concise as you can get.
The problem is though that I can not guarantee that item 1 of the
name array corresponds to item one of the position array.
How so? Unless something on the desktop changes between the first and
second commands, the order should be the same in each case. Do you
have an example of it doing anything different?
Since you're in Cocoa, I'd suggest skipping AppleScript and just send
Apple events directly from ObjC. That way you can take advantage of
native Cocoa classes such as NSArray and NSEnumerator. e.g. Using objc-
appscript (see my sig for links):
// To create Finder glue: osaglue -o FNGlue -p FN Finder