• 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: Scripting Bridge running method passing an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge running method passing an array


  • Subject: Re: Scripting Bridge running method passing an array
  • From: has <email@hidden>
  • Date: Fri, 30 Oct 2009 22:34:22 +0000


On 30 Oct 2009, at 21:38, Kyle Sluder wrote:

On Fri, Oct 30, 2009 at 2:35 PM, has <email@hidden> wrote:
No, the OP's code is passing a *single* reference that identifies *all* of
the speaker objects that match the specified condition.

No. Here is the OP's code:

NSArray *setTheSpeaker;
     setTheSpeaker = [[NSArray alloc]
initWithObjects:connectToThisSpeaker, nil];
[Airfoil connectTo:setTheSpeaker password:nil];

The OP's ObjC code was wrong. His AS code was correct. His understanding of how the AS code worked may have been incorrect; that's not uncommon - many AppleScript users don't properly grok it either.



You are confusing that with the AppleScript he tried to emulate.  I
accurately described what the code he posted did, and that it did not
line up with what he was trying to do.


I think there's some confusion over the confusion. :) You stated: "the command wants an NSArray containing references to "speaker" objects", which is wrong. The command wants a *single reference* that identifies one or more "speaker" objects.

i.e. Even if the OP's ObjC code had passed an NSArray of SBObjects, it would still be wrong. To emulate his AS code, he'd need to use an NSElementArray (which isn't really an array at all, but only pretends [badly] to be one) to as the argument to -connectTo:.


Like I say, Apple event IPC makes absolutely no sense if you try to think about it in OOP terms. AppleScript syntax looks a bit OO-like, which lulls unwary OO programmers into all sorts of misconceptions. But this particular bit of mechanics actually draws on ideas from the world of relational databases, so you'll have more luck viewing it through SQL-coloured glasses than Cocoa-coloured ones.


Hope that clarifies (inasmuch as anything AppleScript-related ever can be),

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Scripting Bridge running method passing an array (From: has <email@hidden>)
 >Re: Scripting Bridge running method passing an array (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Core Data design question: receiving KVO notifications of partially mutated objects
  • Next by Date: Re: Core Data design question: receiving KVO notifications of partially mutated objects
  • Previous by thread: Re: Scripting Bridge running method passing an array
  • Next by thread: xml object memory issue
  • Index(es):
    • Date
    • Thread