• 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: Getting objectSpecifier right...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting objectSpecifier right...


  • Subject: Re: Getting objectSpecifier right...
  • From: Dustin Voss <email@hidden>
  • Date: Sat, 9 Oct 2004 15:44:15 -0700

On 9 Oct, 2004, at 1:13 PM, Doug Knowles wrote:

I'm getting the classic '«class » id 2 of document "Untitled"' response trying to get a reference to an object within my document via AppleScript.

The object in question is a member of a subclass of the class that has the objectSpecifier method (pasted below) which is returning the result.

Right. Gotcha.

A couple of notes:

- I am trying to build an object specifier that identifies the object by unique id within the document; specifying by index would be difficult, and slow if I have to enumerate all objects of the class (I'm anticipating thousands in normal usage).

- I'm fuzzy on what the "class description" argument should be for initWithContainerClassDescription. I assume it should be the class description for the object itself; I tried using both the result of classDescriptionForClass (commented out below), and digging out of the suite registry. But I'm guessing based on various samples I have studied.

Actually, no. It should be the class description for the container. The easiest way to get this is to call (NSScriptClassDescription *) [[self repository] classDescription], assuming I read your code right. There is no need to check with the suite registry.

I wrote a guide for supporting AppleScript with Cocoa—the most complete I've seen—at <http://cocoadev.com/?HowToSupportAppleScript>. If you haven't checked it out already, you should.

- (NSScriptObjectSpecifier *)objectSpecifier
{
NSLog( @"Category: objectSpecifier requested for %@", [self recordDescription] );
// try to specify the category by id
NSScriptObjectSpecifier *containerRef = [[self repository] objectSpecifier];
// NSScriptClassDescription *classDesc = (NSScriptClassDescription *)[NSScriptClassDescription classDescriptionForClass:[Category class]];
NSScriptSuiteRegistry *reg = [NSScriptSuiteRegistry sharedScriptSuiteRegistry];
NSDictionary *classes = [reg classDescriptionsInSuite:@"Prospector"];
NSScriptClassDescription *classDesc = [classes objectForKey:@"Category"];
NSLog( @"...found category description %@", classDesc );
NSNumber *myID = [[NSNumber alloc] initWithLong:[self recordID]];
NSUniqueIDSpecifier *spec = [[NSUniqueIDSpecifier alloc] initWithContainerClassDescription:classDesc containerSpecifier:containerRef key:@"recordID" uniqueID:myID];
return spec;
}
_______________________________________________
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: 
 >Getting objectSpecifier right... (From: Doug Knowles <email@hidden>)

  • Prev by Date: Re: bookmarks bar
  • Next by Date: Re: Getting objectSpecifier right...
  • Previous by thread: Getting objectSpecifier right...
  • Next by thread: Re: Getting objectSpecifier right...
  • Index(es):
    • Date
    • Thread