[q] scriptSuite conflict problems (code included)
[q] scriptSuite conflict problems (code included)
- Subject: [q] scriptSuite conflict problems (code included)
- From: "G. 'Andrew' Tapolow" <email@hidden>
- Date: Wed, 18 Jul 2001 21:21:05 -0700
Hello all,
I am trying to implement a minimal scripting suite into a Cocoa App. The
goal is to be able to do the following calls in an AppleScript:
tell application "JPSB"
set programState to 5
set localVar to programState
end tell
Where programState is an instance variable (with accessors) within my
Controller class. (Apparently, it shouldn't make a difference if I
attach it to a Model class or a controller class)
When I try to open the dictionary in script editor the script editor app
locks up and I get the following error messages in PB's console:
attribute terminology dictionary not found for attribute programState in
class AbstractObject in suite NSCoreSuite
attribute terminology dictionary not found for attribute programState in
class MSBController in suite JPSB
No readable name in dictionary
*** +[NSArray arrayWithObject:]: attempt to insert nil
After a while or if I quit my App ScriptEditor comes back with the error:
"Could not read the dictionary of the application or extension
because of a program error.
The first error line above makes sense as my suite really isn't a
subclass of NSCoreSuite.AbstractObject. The error goes away when I
remove the "Superclass" line in the scriptSuite. I leave it in hoping
(naively) that I will inherit the get and set mechanisms. Beyond that, I
must be missing something.
Below is the scriptSuite and scriptTerminology files in their entirety
(they are short) and the relevant excerpts from the .c and .m files for
the class that I'm trying to attach to.
Everything I've done I've taken from trying to adapt the sketch example
and reading thru the docs:
Making Your Applications Scriptable
Creating Suite Definitions and Suite Terminologies
(found at /Developer/Documentation/Cocoa/ProgrammingTopics/Scripting/)
At this point I'm not exactly sure what I've missed.
Thanks,
Greg A. Tapolow
Stumped by Scripts
Code note: The only difference between the code below and my code is
that MSBController has a different name and the descriptions are written
out. Also, the remainder of the .c and .m files are not relevant to the
issue. If something is missing from the code below, it's probably also
missing from my code.
scriptSuite:
{
"Name" = "JPSB";
"AppleEventCode" = "jpsb";
"Classes" = {
"MSBController" = {
"Superclass" = "NSCoreSuite.AbstractObject";
"Attributes" = {
"programState" = {
"Type" = "NSNumber";
"AppleEventCode" = "prst";
};
};
"AppleEventCode" = "sfbc";
};
};
}
scriptTerminology:
{
"Name" = "JPSB suite";
"Description" = "yadda yadda yadda";
"Classes" = {
"MSBController" = {
"Name" = "controller";
"PluralName" = "controllers";
"Description" = "yadda yadda yadda";
"Attributes" = {
"programState" = {
"Name" = "state";
"Description" = "yadda yadda yadda"; };
};
};
};
}
And just to be sure...I also have:
.h
@interface MSBController : NSObject
{
NSNumber* programState;
...
}
...
- (NSNumber *) programState;
- (void)setProgramState:(NSNumber*)newProgramState;
@end
.m
@implementation MSBController
....
- (NSNumber *) programState
{
return programState;
}
- (void)setProgramState:(NSNumber*)newProgramState;
{
[programState autorelease];
programState = [newProgramState retain];
}
@end