• Figure out if it's worth trying to override performDefaultImplementation for AICreateCommand to try to get rid of that stupid default alloc'ing behavior.
Yes, it is. The trick is to use a private API method to get the implementing class name. Here's the final code block (edit: while the previous code was nice, the new code is actually useful):
- (id)performDefaultImplementation
{
#warning This uses a Private API
NSScriptClassDescription *newObjectDescription = [self createClassDescription];
Class createdClass = NSClassFromString([newObjectDescription implementationClassName]);
id target = [self subjectsSpecifier]; //handy method from Dustin Voss on applescript-implementors
id r;
if ([target respondsToSelector:@selector(makeScriptingObjectOfClass:withParameters:)])
{
//this can do the insert, based on the parameters, methinks.
r = [target makeScriptingObjectOfClass:createdClass withParameters:[self resolvedKeyDictionary]];
}
else
r = [super performDefaultImplementation];
if ([r isKindOfClass:[NSScriptObjectSpecifier class]])
return r;
return [r objectSpecifier];
}
- (id)subjectsSpecifier
{
NSAppleEventDescriptor *subjDesc = [[self appleEvent] attributeDescriptorForKeyword: 'subj'];
NSScriptObjectSpecifier *subjSpec = [NSScriptObjectSpecifier _objectSpecifierFromDescriptor: subjDesc inCommandConstructionContext: nil];
return [subjSpec objectsByEvaluatingSpecifier];
}