Maybe I'm coming at this the wrong way, but in my application I have loadable bundles that add NSMenuItem
entries to the main menu.
I loop over all the bundles and determine what menu items to add, then add them accordingly.
Now the question is, where should such code go in a document-based application?
Initially I put it in my NSDocument subclass' -windowControllerDidLoadNib:
method, but this had the undesired side-effect of repeating the same items n
times, where n
is the number of documents I've opened (i.e. it's not a run-one place to put the code).
So then I tried putting the code in my NSApplicationDelegate
's -applicationDidFinishLaunching:
method, which does mean it only runs once, but I'm facing an issue where the document springs up and displays before -applicationDidFinishLaunching:
executes (or at least before it finishes).
Where's generally the right place to put code that dynamically adds menu items to a document-based application on startup?