• 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
Re: Cocoa and AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa and AppleScript


  • Subject: Re: Cocoa and AppleScript
  • From: matt neuburg <email@hidden>
  • Date: Tue, 27 Apr 2004 07:54:21 -0700

On Thu, 15 Apr 2004 21:05:01 +0200, Lorenzo <email@hidden> said:
>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?

According to p. 36 of my book, it is. Of course, we could *both* be wrong...
:) m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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: xCode 1.2 - hmm
  • Next by Date: Re: Grabbing key presses in NSTableView
  • Previous by thread: Cocoa and AppleScript
  • Next by thread: accessing newly-created files
  • Index(es):
    • Date
    • Thread