I have a handler in my program that opens a Numbers file and dumps data from my array to a table – this handler is only called once a month. Yet, when I open my program, Numbers activates too, even though the handler isn’t called, and before I’ve even run the program. Does anyone know why this happens, and how to stop it?
It’s impossible to answer that without seeing the ASOC class containing the handler that calls Numbers.
And to clarify:
This happens outside of XCode compiling and running. When XCode is quit and you just open your application, Numbers starts up as well? XCode does have to open every application that you call from your code when compiling. But, once compiled, those applications should only need to be opened when called.
I think this answers my question. Numbers does open up when I just open my application. The same thing happens with AppleScript Editor – If the editor is closed, and you open a script with just an empty “Tell application “Numbers” block” in it, Numbers opens as well. Also, if you open AppleScript Editor and then open the library window for an app, that app opens. I wonder if the .sdef files are inside an app, and that app needs to open to interpret any commands you’ve used from that library (I noticed if you search for Numbers.sdef with spotlight, it doesn’t find anything).
Ric
No. I have an ASOC app that can call a bunch of different applications (including another iWork app, Pages). None of them open up when I launch my application. They do get opened when I compile it.
If your application only calls --tell application “Numbers” – in a specific handler/method; AND that handler/method doesn’t get called when your application launches then Numbers should not be opened when your application is.
Can’t help you more than that without seeing the specific code.
When you say “launch my application”, do you mean clicking on the executable file or clicking on the .xcodeproj icon to open it in xcode? The latter is what I meant by “opening my program”-- maybe I should have said “opening my project”. If I click on the Prefix.pch file, for instance, and then quit xcode, when I reopen my project (by clicking on the .xcodeproj icon), that file is what shows up in the lower right of the xcode window, and Numbers does not open. But then when I click on the applescript file to open that in the editor window, Numbers opens. I don’t see any indication in the xcode window that the code is being compiled when I do that. Or, if the script was in the editor window when I closed xcode, then Numbers opens right away when I open my project. This is the behavior I see with the following simple program where nothing is calling the method with the tell block in it:
script NumbersAppDelegate
property parent : class "NSObject"
on doSomething()
tell application "Numbers"
end tell
end doSomething
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
end script
In any case, it doesn’t really matter any more, since I found out that Numbers doesn’t open when I launch my program from its application icon, which is how you would normally open it once you’re done developing it.
Keep in mind that Xcode stores your scripts as text files (.applescript) and therefore has to compile them whenever you open a project – that’s probably what’s launching Numbers.