Getting objectSpecifier right...
Getting objectSpecifier right...
- Subject: Getting objectSpecifier right...
- From: Doug Knowles <email@hidden>
- Date: Sat, 9 Oct 2004 16:13:57 -0400
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.
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.
Any thoughts?
TIA,
Doug K;
- (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