• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa and AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa and AppleScript


  • Subject: Cocoa and AppleScript
  • From: Lorenzo <email@hidden>
  • Date: Thu, 15 Apr 2004 21:05:01 +0200

Hi,
I have an AppleScript which returns a "list" of strings. But I think I am
using a strange Cocoa way to get this list. May you please tell me whether I
am doing right?

My AppleScript is:
------------------
set myList to {}
copy "item_1" to end of myList
copy "item_2" to end of myList
copy "item_3" to end of myList
return myList

My Cocoa code is:
------------------
NSAppleEventDescriptor *mainDesc, subDesc ;

mainDesc = [myAppleScript executeAndReturnError:nil];
if(mainDesc == nil) NSLog(@"mainDesc is nil");
else{
int i, items = [mainDesc numberOfItems];
if(items > 0){
for(i = 1; i <= items; i++){
subDesc = [mainDesc descriptorAtIndex:i];
if(subDesc)
NSLog(@"subDesc %d string: %@", i, [newDesc stringValue]);
}
}
NSLog(@"mainDesc string: %@", [mainDesc stringValue]);
}

I noted that when the list contains one item only,
[mainDesc stringValue] is not null and return the right string.
But, when the list contains more than one item,
[mainDesc stringValue] is null and I have to iterate within the mainDesc to
get all the items. Also the iterator items start from 1. Is all of this
correct?


Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: allow user to drag controls to make their own interface?
  • Next by Date: accessing newly-created files
  • Previous by thread: Re: C++ templates?
  • Next by thread: Re: Cocoa and AppleScript
  • Index(es):
    • Date
    • Thread