• 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 and objectSpecifier issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting and objectSpecifier issue


  • Subject: Re: Scripting and objectSpecifier issue
  • From: Dustin Voss <email@hidden>
  • Date: Sat, 2 Oct 2004 15:57:12 -0700

On 1 Oct, 2004, at 8:24 PM, Joseph Jones wrote:

I am trying to make my app scriptable and I have run into a loggerhead.
Basically, if I try to stash one of my objects into an AS variable and user
it later I get an AS error stating that the command can not be created. If I
look into the event log for AS I see that the name of my class is <<class>>
id XXXXXX instead of projectitem id XXXXXX. When I turn CocoaScripting debug
output on, it appears that the want keyword is holding a NULL value
(0x00000000) instead of "Pitm" which is the code for the class I am trying
to use.

I am building an NSUniqueIDSpecifier to describe my class and I can't figure
out why it is showing the class as <<class>>. The two parents in the
containment hierarchy both override objectSpecifier and both parents can be
stored and retrieved ( as document id XXXXXX and project id XXXXXX ).

I am at my wits end here. I searched the archives for this bit haven't
located what I need to figure this out. The best advice I've seen is to
implement objectSpecifier, which I have done.

Can anyone enlighten me as to what I am doing wrong (or need to do) to
resolve this?

Generally, this problem is caused by an improperly-written objectSpecifier method. When you are building the specifier, you need to include the container's class description and object specifier, and the proper KVC key to get from the container to your object.

For an NSUniqueIDSpecifier, your code should look like this:

- (NSScriptObjectSpecifier *) objectSpecifier
{
NSUniqueIDSpecifier *specifier = [[NSIndexSpecifier alloc]
initWithContainerClassDescription:
(NSScriptClassDescription *)[myContainer classDescription]
containerSpecifier: [myContainer objectSpecifier]
key: @"projectitems"];
[specifier setUniqueID: /* an appropriate string or number */];
return [specifier autorelease];
}

You'll notice the "myContainer" variable. A scriptable object needs to have a pointer to its container. When you create this scriptable object, set the pointer to the parent scriptable object. If the parent object is the application itself, use the class description returned by (NSScriptClassDescription? *)[NSApp classDescription].

You stated that the "project" AS class has an element called "projectitems" (you should stick a space in there, btw); I assumed the KVC key for that is also @"projectitems". Whatever the KVC is, use that for the "key:" parameter.

If you haven't seen it yet, take a look at <http://cocoadev.com/?HowToSupportAppleScript>. It explains most everything you need to know.

And if it still doesn't work, ask again on Apple's applescript-implementors list.

_______________________________________________
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
References: 
 >Scripting and objectSpecifier issue (From: Joseph Jones <email@hidden>)

  • Prev by Date: [ANN] Extending MacPAD - public discussion
  • Next by Date: Re: Getting NSTIFFPboardType data from an NSTextView
  • Previous by thread: Re: Scripting and objectSpecifier issue
  • Next by thread: NSScanner problem
  • Index(es):
    • Date
    • Thread