views:

50

answers:

1

I am making a Cocoa NSDocument-based app scriptable. If I try to create a new document with the following AppleScript:

tell application "MyApp" to make new document

a new document is created, but its title is nil. Any ideas on why this would happen and how to fix it?

+1  A: 

I took a quick look at the TextEdit developer example code (/Developer/Examples/TextEdit) to see if it sheds any light on this. There's a comment in Document.m's -init method that says:

// Assume the default file type for now, since -initWithType:error: 
does not currently get called when creating documents using 
AppleScript. (4165700)

Could that have something to do with the problem? Do you have multiple document types defined?

If that's not it, you might want to post your .scriptsuite and .scriptterminology files.

Joshua Nozzi
That has something to do with the problem. When I make that change, 'tell application "MyApp" to make new document' now returns 'document "Untitled" of application "MyApp"', like it should, but my app does not open up a new window. This is the same behavior I see if I create a default NSDocument application in Xcode and enable scriptability.
Stephen