• 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: AppleScipt & Cocoa, argh! I can't get it to work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScipt & Cocoa, argh! I can't get it to work


  • Subject: Re: AppleScipt & Cocoa, argh! I can't get it to work
  • From: Greg Titus <email@hidden>
  • Date: Wed, 10 Apr 2002 18:08:41 -0700

You need to implement the -objectSpecifier method on your Stuff class. Cocoa's AppleScript support calls this method to turn your object into a reference to give to AppleScript.

In your simple case it should look like:

- (NSScriptObjectSpecifier *)objectSpecifier;
{
NSScriptObjectSpecifier *containerRef = [NSApp objectSpecifier];

return [[[NSIndexSpecifier alloc] initWithContainerClassDescription:[containerRef keyClassDescription] containerSpecifier:containerRef key:@"stuff" index:0] autorelease];
}

(See Sketch for a more complete example.)

Hope this helps,
--Greg

On Wednesday, April 10, 2002, at 02:29 PM, Nat! wrote:

I am still stuck in AppleScript and Cocoa. Maybe someone has an idea, what's going on/wrong ?

I have a NSApplication subclass called "Application" that provides objects of class "Stuff" in an NSArray. There is always one object in the "stuffs" array. The ScriptEditor reads my script suite correctly.

My test script is this:

tell application "AppleScriptTest"
set x to stuff 1
end tell

It works in as much, that it doesn't produce an error. Alas the variable 'x' does not get set. When I look into the event log I see:

tell application "AppleScriptTest"
get stuff 1
end tell

I see that there is no result sent back. A successful event log should look something like this

tell application "Sketch"
get document 1
--> stuff 1
end tell


So I wrote a little poser on NSScriptCommand to get some tracing facility in Cocoa too (It's appended in the back). The trace output shows that my method did return a "Stuff", it just seems to get lost somewhere.

[here is the trace, somewhat beautified for readability. The log comes from -[NSScriptCommand executeCommand] ]

-> Execute Command: NSCoreSuite.Get
Direct Parameter: <NSIndexSpecifier: stuffs 1>
Receivers: <NSIndexSpecifier: stuffs 1>
Arguments: {}
<- Stuff:<Stuff: 0x975b0>

hmmm.... The stuff gets send back from my code into the Cocoa machinery, but then it vanishes.

If anyone can help, It'd be great. Appended are various relevant files.

Cheers
Nat!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: AppleScipt & Cocoa, argh! I can't get it to work
      • From: Nat! <email@hidden>
References: 
 >AppleScipt & Cocoa, argh! I can't get it to work (From: Nat! <email@hidden>)

  • Prev by Date: Re: Quick PB localization question
  • Next by Date: Re: Open Resource File with Cocoa Path
  • Previous by thread: AppleScipt & Cocoa, argh! I can't get it to work
  • Next by thread: Re: AppleScipt & Cocoa, argh! I can't get it to work
  • Index(es):
    • Date
    • Thread