Sometimes this just doesn't work, because Cocoa doesn't like your title: -p This happens, for example. when the name you choose is the localized name of the application, but it wants to display the non-localized name of the application. A little trick can help ...
NSMenu *menu = [[[NSApp mainMenu] itemAtIndex:0] submenu]; NSString *title = @"My app name";
Yes, this is crazy, but this extra character eventually changed everything. (You can also add just SPACE, but then the menu item grows, which is probably not the way you want.)
Tested on OS X 10.9.5.
Other:
You must do all this AFTER you have shown the window. Otherwise, it just won't work. In addition, if you perform this procedure when you start the application, and then later, when a window appears, do it again, this may not work.
source share