if you have a document based application you actually don’t have to do anything.
In MainMenu.xib the menu item New is connected to First Responder with the newDocument: method
which opens a new document specified in Document.xib
on will finish launching theObject
(*"Called from the application object just prior to completion of launching."*)
set controllers to {}
set folder_items to list folder mac_path without invisibles
repeat with an_item in folder_items
if an_item ends with ".pdf" then
call method "performActionForItemAtIndex:" of object (menu 2 of main menu) with parameter 0 -- 0 = first menu item
set title of (window of first document) to an_item
end if
end repeat
end will finish launching
This code goes in a loop since the call method command triggers the on will finish launching event handler.
I thought that this event handler set in File Owner only was triggered when the actual application was launched. It isn’t triggered when i manually create a new window, just when i use the call method.
Very strange.
If I for example do call method from within a “on clicked” event handler it doesn’t run “on will finish launching” again. It’s just when the call from that specific handler.
as far as I know, the will finish launching handler is only affected by (NS)application,
that means, it will be called once (if enabled) at the end of the application launching process