{"id":163,"date":"2008-10-29T09:21:31","date_gmt":"2008-10-29T14:21:31","guid":{"rendered":"http:\/\/vgable.com\/blog\/2008\/10\/29\/two-help-menus\/"},"modified":"2008-10-29T09:21:32","modified_gmt":"2008-10-29T14:21:32","slug":"two-help-menus","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2008\/10\/29\/two-help-menus\/","title":{"rendered":"Two Help Menus"},"content":{"rendered":"<p>I ran into an issue at work where sometimes an application would have two &#8220;Help&#8221; menus, on OS X 10.5 &#8220;Leopard&#8221; (but not on OS X 10.4 &#8220;Tiger&#8221;).  The problem was interacting with the UI before the application had finished enough of <a href=\"http:\/\/cocoawithlove.com\/2008\/03\/cocoa-application-startup.html\">the AppKit-initialization process<\/a>.<\/p>\n<p>The application had to install a component, which involved displaying authentication dialogs and such.  Because the component was necessary for the application to work correctly, I thought it would be safest to do this as early as possible.  But displaying a dialog in code called from <code><a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/ApplicationKit\/Protocols\/NSNibAwaking_Protocol\/Reference\/Reference.html#\/\/apple_ref\/occ\/instm\/NSObject\/awakeFromNib\">awakeFromNib<\/a><\/code> ended up being the cause of the double Help Menu issue.<\/p>\n<p>Waiting until <code><a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/ApplicationKit\/Classes\/NSApplication_Class\/Reference\/Reference.html#\/\/apple_ref\/occ\/instm\/NSObject\/applicationWillFinishLaunching:\">applicationWillFinishLaunching<\/a>:<\/code> or <code><a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/ApplicationKit\/Classes\/NSApplication_Class\/Reference\/Reference.html#\/\/apple_ref\/occ\/instm\/NSObject\/applicationDidFinishLaunching:\">applicationDidFinishLaunching<\/a>:<\/code> to interact with the user fixed the problem.  (In my case, it was safe to defer the installation until then.)<\/p>\n<p>I am not aware of any other issues from putting up a window &#8220;too early&#8221; &#8230; however, it seems to me that doing it is asking for trouble.  The AppKit\/Cocoa environment obviously isn&#8217;t 100% ready at that point.  Why risk running your code with half-baked libraries if you don&#8217;t have to?<\/p>\n<p>Whenever possible, I will defer &#8220;first run&#8221; behavior until <code>applicationWillFinishLaunching:<\/code> or <code>applicationDidFinishLaunching:<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I ran into an issue at work where sometimes an application would have two &#8220;Help&#8221; menus, on OS X 10.5 &#8220;Leopard&#8221; (but not on OS X 10.4 &#8220;Tiger&#8221;). The problem was interacting with the UI before the application had finished enough of the AppKit-initialization process. The application had to install a component, which involved displaying [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,6,38,3,5,4],"tags":[211,210,212],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-bug-bite","category-cocoa","category-interface-builder","category-macosx","category-objective-c","category-programming","tag-appkit","tag-awakefromnib","tag-nsapplication"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":0,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}