• 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: How to support 'every' object in script interface
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to support 'every' object in script interface


  • Subject: Re: How to support 'every' object in script interface
  • From: Bill Cheeseman <email@hidden>
  • Date: Sun, 26 Jun 2005 13:55:21 -0400

on 2005-06-26 1:17 PM, Steve Palmer at email@hidden wrote:

> and the console log shows:
>
>      Direct Parameter: <NSPropertySpecifier: bar>
>      Receivers: <NSPropertySpecifier: bar>
>      Arguments: {}

I'll quote what I recently wrote to someone else about direct parameter
handlers for lists and 'every'. Perhaps it will be helpful. --

-->
In Tiger with an sdef, my code comments remind me that:

1. When the direct parameter is an AppleScript list ('get {a, b, c}'), it is
interpreted as an array containing multiple instances of
NSScriptObjectSpecifier, each of them specifying an object.

2. When the direct parameter is 'every', it is interpreted as a single
NSScriptObjectSpecifier, specifying an array of objects.

So, just make sure your command handler branches correctly to handle the
difference between these two situations. Here's how I do it, with some
simplification:

a. Get directParameter and test it to see if it
isKindOfClass:[NSPropertySpecifier class] and, if so, if it evaluates to
isKindOfClass:[NSArray class]. If it does, you know you're dealing with the
'every' case -- case 2, above. Iterate the array and do what you will with
its elements.

b. Else, you know the direct parameter was of the form '{a, b, c}', as in
case 1, above. So, iterate the array of NSScriptObjectSpecifiers, calling
objectsByEvaluatingSpecifier on each of them and then doing with it what you
will.
<--

The above is for an sdef-only app running on Tiger (with the
OSAScriptingDefinition key defined in Info.plist. If you're running under
Panther and older, the situation is a little different. In Panther and
older, AppleScript will send the 'every' case to your class, while sending
the list case to your application delegate. I'm not saying this quite right,
I think, but the basic idea is that you have to have a handler in both
classes to catch both list and 'every' in Panther and older.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to support 'every' object in script interface
      • From: Steve Palmer <email@hidden>
References: 
 >Re: How to support 'every' object in script interface (From: Steve Palmer <email@hidden>)

  • Prev by Date: NSArrayController: delay in setting selection, inserting item?
  • Next by Date: Re: NSArrayController: delay in setting selection, inserting item?
  • Previous by thread: Re: How to support 'every' object in script interface
  • Next by thread: Re: How to support 'every' object in script interface
  • Index(es):
    • Date
    • Thread